I have this code
$XMLTranslationObject = new DOMDocument();
$XMLTranslationObject->load("../xdata/xml/translation/en-US/profile.xml");
$Xpath = new DOMXpath($XMLTranslationObject);
$Result = $Xpath->evaluate("Field[@Name = 'AttachedFiles']")->nodeValue;
echo $Result;
and the xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Translation language="en-US">
<!-- Basic Begin -->
<Field Name="SiteName">Brainfavor</Field>
<Field Name="Error">Error</Field>
<!-- Basic End -->
<!-- Header Begin -->
<Field Name="Name">Name</Field>
<Field Name="WorkingAt">Working at</Field>
<Field Name="Phone">Phone</Field>
witch gives me the following error
Notice: Undefined property: DOMNodeList::$nodeValue in C:\xampp\htdocs\brainbook\profile\loadmore.php on line 30
All i want is to retrieve the value of a row where field name is AttachedFiles
, just run a simple Xpath query and retrieve the result. Using XSLT it is easy
<xsl:value-of select="$TranslationProfile/Field[@Name = 'AttachedFiles']"/>
but i didn't used PHP Xpath before.