Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to parse '<item id=12>'

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top