read xml files with namespaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am writing code to read a bunch of xml files which describe pharmaceutical drugs. They have namespace references at the top of each file that look like this:

<document xmlns:voc="http://www.hl7.org/v3/voc"; xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="urn:hl7-org:v3 http://www.fda.gov/oc/datacouncil/schemas/spl/spl.xsd";>

I am having a challenging time coming up with an xpath query that works even after registering a namespace like this:

 $xpath->registerNamespace("voc","http://www.hl7.org/v3/voc"; );

I am trying a query like this:

$qry = '//component' ;
$nodeList = $xpath->query($qry);

I can't seem to make it work.  Could someone please advise?

thanks
Selwyn


The whole program looks like this:

$dom=new DOMDocument;
$dom->load('./828C40F4-5969-4254-9008-36AF15CC601B.xml') ;
$qry = '//component' ;
$nodeList = $xpath->query($qry);

header('Content-Type: text/plain');
foreach ($nodeList as $node)
{
    echo $dom->saveXML($node) . "\r\n";
}



--
Selwyn Polit
Computer Consulting, programming, web sites
512-696-0410
www.AustinProgressiveCalendar.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux