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?
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?