I am trying to access the text value of an xml element. I use SimpleXMLElement. I have to miss something obvious.
<h:html xmlns:jr="http://openrosa.org/javarosa" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ex="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/2002/xforms">
<h:head>
<h:title>NewForm</h:title>
</h:head>
</h:html>
$xml = new SimpleXMLElement($resp);
$xml->registerXPathNamespace('h', 'http://www.w3.org/1999/xhtml');
$result = $xml->xpath('//h:title');
debug($result);
Executing the above code gives me:
array (
0 =>
SimpleXMLElement::__set_state(array(
0 => 'NewForm',
)),
)
It seems very simple. I find it difficult to get the value "NewForm"
I tried
$result[0], $result[0]->{0}, $result[0][0].
Iterate through child elements $result[0].
Did someone help me in the right direction so that I can get the text from the title element?
source
share