tiki Posted April 3, 2007 Share Posted April 3, 2007 I tried domxpath but failed. So whats an easy way to grab the value "Swordsman" and return it. <human> <units> <light> <name>Swordsman</name> </light> </units> </human> Link to comment https://forums.phpfreaks.com/topic/45456-easiest-way-to-grab-an-xml-nodes-value/ Share on other sites More sharing options...
joquius Posted April 3, 2007 Share Posted April 3, 2007 document.getElementsByTagName('name')[0].childNodes[0].nodeValue; but thats js Link to comment https://forums.phpfreaks.com/topic/45456-easiest-way-to-grab-an-xml-nodes-value/#findComment-220711 Share on other sites More sharing options...
tiki Posted April 3, 2007 Author Share Posted April 3, 2007 document.getElementsByTagName('name')[0].childNodes[0].nodeValue; but thats js And this is a php forum Link to comment https://forums.phpfreaks.com/topic/45456-easiest-way-to-grab-an-xml-nodes-value/#findComment-220715 Share on other sites More sharing options...
joquius Posted April 3, 2007 Share Posted April 3, 2007 well I don't know, preg_match_all ("/<name>[^<]*<\/name>/", $xml, $names); and if you like foreach ($names[0] as $name) $_names[] = preg_replace ("/<name>([^<]*)<\/name>/", "$1", $name); Link to comment https://forums.phpfreaks.com/topic/45456-easiest-way-to-grab-an-xml-nodes-value/#findComment-220716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.