Asked 8 years ago
21 Oct 2016
Views 1003
sqltreat

sqltreat posted

how to deal with xml in php ?

I am using get SOAP and getting result in xml format . now i want to read particular element value. how can i get it with php?
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

suppose you have test.xml in same folder of script


 $responsedom = new DomDocument ();
$responsedom->loadXML ( file_get_contents("test.xml") );
$elements= $responsedom->getElementsbyTagName("Entities");


getElementsbyTagName will search element with name and return array of object .

foreach ( $elements as $element) {
	$keyValueString=$element->getElementsbyTagName( "KeyValuePairOfstring" );
       $value=$keyValueString->firstChild->textContent;


}


i think this should be work

Post Answer