Looking for simple example for parsing a XML-file
by Jarle H. Knudsen other posts by this author
Aug 8 2005 1:54PM messages near this date
view in the new Beta List Site
Q: XML::XPath, node_global_pos ?
|
RE: Looking for simple example for parsing a XML-file
& XSLT I'm trying to find out how I can parse an XML-file using Perl, and I'm
having trouble finding working example that can introduce me to this.
Here is an example of what I need to do:
Given this XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<course name="My Course">
<chapter number="01" name="Chapter 1">
<text> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</text>
<bullet> This is a bullet</bullet>
<text> Duis ultricies. Phasellus augue sapien, auctor ac.</text>
</chapter>
<chapter number="02" name="Chapter 2">
<text> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</text>
</chapter>
</course>
the following should be done:
- Create directory "My Course"
- Create directory "My Course/Chapter 1"
- Create file "My Course/Chapter 1/text1" containing "Lorem ipsum
dolor sit amet, consectetuer adipiscing elit."
- Create file "My Course/Chapter 1/bullet2" containing "This is a
bullet"
- Create file "My Course/Chapter 1/text3" containing " Duis
ultricies. Phasellus augue sapien, auctor ac."
- Create directory "My Course/Chapter 2"
- Create file "My Course/Chapter 2/text1" containing "Lorem ipsum
dolor sit amet, consectetuer adipiscing elit."
As you can see, the order of the nodes is important, so I can't use
XML::Simple.
Any help, hints, examples, which module to use, etc. is appreciated.
Best regards,
Jarle Hammen Knudsen
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Jarle H. Knudsen
Stuart Arnold
Jarle H. Knudsen
Mark - BLS CTR Thomas
|