Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > Perl
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 14th, 2007, 12:33 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in XML parsing

Hi All,

I have to parse on XML file that looks like

<Name>
<Name1>JESSICA HYNES</Name1>
<Name2>DERIK O'BRIEN</Name2>
<Name3>DENZIL</Name3>
</Name>

But when I parse it, I dont get some missing data like

JESSICA HYNES|DERIK|DENZIL

You can see O'BRIEN is missing because of ' I guess

Please give me some solution for this

Denzil

Reply With Quote
  #2 (permalink)  
Old June 14th, 2007, 11:20 AM
Friend of Wrox
Points: 1,515, Level: 15
Points: 1,515, Level: 15 Points: 1,515, Level: 15 Points: 1,515, Level: 15
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2003
Location: Oxford, , United Kingdom.
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
quote:
Please give me some solution for this
Show us your code and we might...

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk
Reply With Quote
  #3 (permalink)  
Old April 5th, 2008, 03:01 AM
Registered User
 
Join Date: Jun 2007
Location: Rohtak, Haryana, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Show me your code and we might...



:D


Reply With Quote
  #4 (permalink)  
Old December 18th, 2008, 03:56 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default use this code. i wrote it before long back with out parser. might be useful to you

################################################## #####################
#to parse an xml file #
#model file is given in file.xml #
#file should have only one tag pairs in a line #
################################################## #####################

#!/usr/bin/perl
$filename=$ARGV[0];
open (FILE, "$filename") || die "Can't open $filename : $!\n";
@contents=<FILE>;
close(FILE);
$i=0;
$flag=0;
foreach $line (@contents)
{
$line=~s/>$/ /;
unless($line=~m/(.*>)/)
{
$lonelytag=$line;
$lonelytag=~s/<//;
if($lonelytag=~s/\///)
{

if($flag == 0)
{
print "\n\t$lonelytag\n";
print "@tag\n";
}
print "@value\n";
$i=0;
undef $value;
$flag++;
}

}

else
{
if(($line=~m/(^.*>)(.*<)/))
{
$tag[$i]=$1;
$value[$i]=$2;
$tag[$i]=~s/<//;
$tag[$i]=~s/>/ /;
$value[$i]=~s/<//;
$value[$i]=~s/$/ /;
$i++;
}
}
}
print "\n";


let me kwow if you need any info,
- Nazir
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing the xml which is having vikkiefd XML 14 July 28th, 2008 06:21 AM
parsing xml kri_hegde XML 5 July 24th, 2007 12:37 PM
XML parsing denzil_cactus Perl 0 June 11th, 2007 03:34 AM
XML Parsing Problem when using MSXML magicwanda XML 1 December 9th, 2004 01:56 PM
XML Parsing tgopal Javascript 2 July 27th, 2004 09:54 AM



All times are GMT -4. The time now is 03:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.