in reply to Re: How do I ignore comments in an xml file when using win32::ole?
in thread How do I ignore comments in an xml file when using win32::ole?
@choroba, I'm a mere systems engineer trying to parse xml :) I've used xml::simple before, but that doesn't work with the file I have now. So I went with the search that gave me the easiest example to read and follow.
@toolic, Thanks for the example. I didn't know what to do with the xml that you added into the code. I tried reading it in a few ways, didn't help. I have to read a file that I download from a repository and have to load it into my parser
However, thanks to your example, I explored XML::TWIG more and figured out a way to do this.
This link was very helpful
http://www.xml.com/pub/a/2001/04/18/perlxmlqstart1.html
use warnings; use strict; use XML::Twig; my $file = './test.xml'; my $twig = XML::Twig->new(); $twig->parsefile($file); my $root = $twig->root; foreach my $item ($root->children('Main')){ print $item->att('id').", ".$item->att('name'); print "\n"; }
This gave me the desired output.
1, Item1
2, Item2
4, Item5
@AnomalousMonk, I won't claim to be any sort of expert with xml. To me, if internet explorer grey'ed it out, and Visual SlickEdit "green"ed it out, I take it it's a comment in the XML. :)
Thanks for all your help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I ignore comments in an xml file when using win32::ole?
by toolic (Bishop) on Jun 25, 2011 at 19:45 UTC |