XML ::SIMPLE

XML ::SIMPLE

am 02.11.2004 13:05:23 von eva.horn

Hey!
Does the XML SIMPLE Modul work if i only want to get the content of the
text between the tags?
I want to parse this xmlfile so that there is just CHINA,Hallo,27832
Or do i have to use the Modul XML parser?


china




Hallo
PubMed
27832
Ok







--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

RE: XML ::SIMPLE

am 02.11.2004 14:16:46 von Bob Showalter

E.Horn wrote:
> Hey!

Back for another bite at this apple I see...

> Does the XML SIMPLE Modul work if i only want to get the content of
> the text between the tags?

Of course. Have you tried it?

> I want to parse this xmlfile so that there is just CHINA,Hallo,27832

OK.

> Or do i have to use the Modul XML parser?

Well, XML::Simple uses XML::Parser by default. You could extract the data
using only XML::Parser. Or any of a host of other modules.

As I and others have told you before, you need to get a basic understanding
of the XML parsing concepts by studying something like
http://perl-xml.sourceforge.net/faq/. If you just want to get this problem
solved and not bother with the learning process, perhaps you need to hire
someone to write this part of the program for you.

It's trivial to write a program to extract the values you're looking for
from the example you gave. If your data varies (i.e. multiple 's
per ), you'll have to consider some of the options that XML::Simple
has for constructing the tree.

Or, perhaps an XPath approach like XML::XPath would be better, as others
have pointed out to you.

For XML::Simple, try the little program below. It will dump out the tree
built by XML::Simple. Then you can see how to retrieve the values you're
interested in...

#!/usr/bin/perl

use XML::Simple;
$x = XMLin(\*DATA);
use Data::Dumper;
print Dumper($x);
__DATA__


china




Hallo
PubMed
27832
Ok







--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org