Last active
March 2, 2019 09:46
-
-
Save lynt-smitka/6a50bdf97bb32a64e34b to your computer and use it in GitHub Desktop.
Pohoda Parse XML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$content = '<?xml version="1.0" encoding="Windows-1250"?> | |
<dat:dataPack id="Za001" ico="12345678" application="StwTest" version="2.0" note="export" | |
xmlns:dat="http://www.stormware.cz/schema/version_2/data.xsd" | |
xmlns:stk="http://www.stormware.cz/schema/version_2/stock.xsd" | |
xmlns:ftr="http://www.stormware.cz/schema/version_2/filter.xsd" | |
xmlns:lStk="http://www.stormware.cz/schema/version_2/list_stock.xsd" | |
xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd"> | |
<dat:dataPackItem id="a55" version="2.0"> | |
<lStk:listStockRequest version="2.0" stockVersion="2.0"> | |
<lStk:requestStock> | |
<ftr:filter> | |
<ftr:code>Z220</ftr:code> | |
</ftr:filter> | |
</lStk:requestStock> | |
</lStk:listStockRequest> | |
</dat:dataPackItem> | |
</dat:dataPack>'; | |
$xml = new SimpleXMLElement($content); | |
$ns = $xml->getDocNamespaces(); | |
var_dump($xml->children($ns['dat'])->dataPackItem->children($ns['lStk'])->listStockRequest->requestStock->children($ns['ftr'])->filter->code); |
Quick & dirty one ?
$code = $xml->xpath('//ftr:code');
echo $code[0];
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. I published my version at https://gist.github.com/mikaelz/288d1611eec0f80c1293