Re: getting the right XML tag in the parse.
- From: Michael Fesser <netizen@xxxxxx>
- Date: Fri, 18 Jul 2008 17:51:35 +0200
..oO(news@xxxxxxxxxxxxxx)
I'm trying to parse an XML formatted post reply, and I can't figure
out how to get the value of the right tag.
The XML is formatted like this:
<A>
<foo>val1</foo>
</A>
<B>
<foo>val2</foo>
</B>
<BAR>
val3
</BAR>
If this is the entire document, then it's not well-formed XML, because
there's no root element.
I need the value of A's "foo", not B's "foo". But from what I can find
I can only get the value of the lowest nested tag in a nest. i.e.:
"foo" or "BAR". Not specifically A or B's "foo".
Of course you can access every element and every attribute in the tree.
Just use the right tools.
Below is the script I'm using. In this case "TOTALCHARGES" is the
"foo" I'm looking for, but I need it to specifically get A's and not
B's.
If someone can point me to where I can find out how, I'd appreciate
it!
[...]
You don't have to write your own parser. Use the SimpleXML extension
with some XPath expressions to get all the nodes you want.
Micha
.
- Follow-Ups:
- Re: getting the right XML tag in the parse.
- From: news@xxxxxxxxxxxxxx
- Re: getting the right XML tag in the parse.
- References:
- getting the right XML tag in the parse.
- From: news@xxxxxxxxxxxxxx
- getting the right XML tag in the parse.
- Prev by Date: getting the right XML tag in the parse.
- Next by Date: How to read CSV and update Mysql
- Previous by thread: getting the right XML tag in the parse.
- Next by thread: Re: getting the right XML tag in the parse.
- Index(es):
Relevant Pages
|