trouver des attributs et leur valeur avec xpath
Posté : 28 oct. 2015, 23:37
Bonsoir,
Je souhaite importer certains attributs XML-TEI dans un BD mysql existante.
Pour le moment, je cherche ces attributs avec xpath de SimpleXML.
Je suis complètement néophyte, donc je tâtonne.
Est-ce que la classe SimpleXMLElement::xpath est correcte ?
Une suggestion ?
D'avance, merci.
McCallum
Je souhaite importer certains attributs XML-TEI dans un BD mysql existante.
Pour le moment, je cherche ces attributs avec xpath de SimpleXML.
Je suis complètement néophyte, donc je tâtonne.
Est-ce que la classe SimpleXMLElement::xpath est correcte ?
<?php
$string = <<<XML
<w type="headword" subtype="unvocalized">šbʿ</w>
XML;
$xml = new SimpleXMLElement($string);
/* ici je cherche @headword */
$result = $xml->xpath('headword');
while(list( , $node) = each($result)) {
echo 'headword: ',$node,"\n";
}
?>
Manifestement, j'ai dû faire une erreur car rien de s'affiche, alors pour que @type headword šbʿ devrait s'afficher.Une suggestion ?
D'avance, merci.
McCallum