so I have this XML which I'm trying to read via SimpleXML class of php.
<ns0:ASN xmlns:ns0="http://ift.tt/XWuFB0">
<CustPackingSlipJour xmlns="http://ift.tt/XWuFB0" class="entity">
<BON_FileNameSeqNum>4</BON_FileNameSeqNum>
<!-- funktionell: Internt löpnr -->
<BON_TotalNetAmount>726.00</BON_TotalNetAmount>
<!-- funktionell: Totalt belopp -->
<BON_TotalTaxAmount>181.50</BON_TotalTaxAmount>
<!-- funktionell: Momsbelopp -->
<InvoiceAccount>9001</InvoiceAccount>
<!-- funktionell: -->
<LanguageId>SV</LanguageId>
<!-- funktionell: Språk -->
<OrderAccount>9001</OrderAccount>
<!-- funktionell: Butiks nr för intern användning! -->
<Qty>4.00</Qty>
<!-- funktionell: Total lev kvant! -->
<SalesId>24</SalesId>
<!-- funktionell:Försäljningsordernr! -->
<CustPackingSlipTrans class="entity">
<BON_LineNetAmount>149.00</BON_LineNetAmount>
<!-- funktionell: Orderradsbelopp! -->
<BON_SalesPrice>0.00</BON_SalesPrice>
<!-- funktionell: Försäljningspris! -->
<DeliveryDate>2014-09-09</DeliveryDate>
<!-- funktionell: Leveransdag! -->
<ItemId>10001</ItemId>
<!-- funktionell: Artikelnr! -->
<Ordered>1.00</Ordered>
<!-- funktionell:Beställd kvantitet! -->
<PackingSlipId>00000004_061</PackingSlipId>
<!-- funktionell: -->
<Qty>1.00</Qty>
<!-- funktionell:Levererad kvantitet! -->
<InventReportDimHistory class="entity">
<InventDim class="entity"/>
</InventReportDimHistory>
</CustPackingSlipTrans>
I'm trying to access it's element by the code :-
<?php
$asn=simplexml_load_file("ASN.xml");
echo $asn->CustPackingSlipTrans[0]->ItemId;
?>
But this doesn't seems to be working. I get a blank output. I've read some tutorials bout the Simplexml class and reached to this code. But I'm not sure what wrong I'm doing here. How would I access each and every element of the XML ?
All suggestions are appreciated.
No comments:
Post a Comment