The goal is to be able to extract a specific element (and all children of it) from a XML string and then to echo this to the page inside a hidden form element so that it can be posted to another page.
I have tried to get the XML chunk printed to the page but cannot get it. I have got the XPath to select the chuck of XML I want but what I can't figurer out is how to then print this to the page.
//Response holds the xml returned from the third party service $xml = simplexml_load_string($response); $toPost = $xml->xpath("Accommodations/AccommodationSegment[@ItineraryId='".$someVariable."']/descendant-or-self::*"); echo htmlentities($toPost);
Nothing gets printed out for the above code. I can however do a print_r() on the $toPost variable and see the SimpleXML object.
But I really need just the chunk of XML that the Xpath selected.
Thank you to anyone who can help me with this.