How to parse via PHP '<item id=12>'
- From: "Francesco Moi" <franscescomoi@xxxxxxx>
- Date: 21 Jul 2005 10:23:53 -0700
Hi.
Working with 4.3.11, I'm trying to parse an XML document:
------------
<doc>
<item id=1>Richard</item>
<item id=2>Mary</item>
</doc>
----------
I'm trying to get '1' and '2'
If I want to get 'Richard' or 'Mary' I use:
----------
xml_set_element_handler($parser, "open_tag", "close_tag");
xml_set_character_data_handler($parser, "tag_contents");
function close_tag($parser, $name)
{
global $contents;
$contents = trim($contents);
switch($name)
{
case "ITEM":
print("$contents\n");
break;
}
}
-------------------
But no idea about getting '1' or '2'. Any suggestion?
.
- Prev by Date: fsockopen not resolving domain to correct IP address
- Next by Date: Re: Weirdness
- Previous by thread: fsockopen not resolving domain to correct IP address
- Next by thread: How to Handle Bounced-Back Email with PHP
- Index(es):
Relevant Pages
|
|