I've got xml file:
<?xml version="1.0" ?>
<xml>
<opis lang="en">My text</opis>
<opis lang="cz">My text2</opis>
</xml>
I want to get "My text2" - so a node where attribute lang is "cz":
$xml = simplexml_load_file($fileName);
$result = $xml->xpath('//xml/opis[@lang="cz"]')
but instead of value I get:
array(1) (
[0] => SimpleXMLElement object {
@attributes => array(1) (
[lang] => (string) cz
)
}
))
You could get the value like this:
Try using DomDocument: