尝试在此处阅读文件时,不会返回任何内容......
我做错了什么?
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ccts="urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:ns7="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:sdt="urn:oasis:names:specification:ubl:schema:xsd:SpecializedDatatypes-2" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"><cec:UBLExtensions xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"><cec:UBLExtension><cec:ExtensionURI>urn:oasis:names:specification:ubl:profile:dsig:signature</cec:ExtensionURI><cec:ExtensionContent><sig:UBLDocumentSignatures xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2"><sig:SignatureInformation><cbc:ID>urn:oasis:names:specification:ubl:signatures:1</cbc:ID><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"><XPath>count(ancestor-or-self::sig:UBLDocumentSignatures | here()/ancestor::sig:UBLDocumentSignatures[1]) > count(ancestor-or-self::sig:UBLDocumentSignatures)</XPath></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>Agc2+1rOPYaPgixs6RTiLZzoj4H5/96eA8nv6dlU6yA=</DigestValue></Reference></SignedInfo><SignatureValue>Mp3ziREg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zXobKb+2+aMf7KiAg1wHPUcyKx2c5nplgqQ7Hwldk9S9yzaRsYEGWT
+xpSUA==</X509Certificate></X509Data></KeyInfo></Signature></sig:SignatureInformation></sig:UBLDocumentSignatures></cec:ExtensionContent></cec:UBLExtension></cec:UBLExtensions>
<cbc:UBLVersionID>2.0</cbc:UBLVersionID>
<cbc:CustomizationID>OIOUBL-2.01</cbc:CustomizationID>
<cbc:ProfileID schemeAgencyID="320" schemeID="urn:oioubl:id:profileid-1.2">urn:www.nesubl.eu:profiles:profile5:ver2.0</cbc:ProfileID>
<cbc:ID>10</cbc:ID>
<cbc:IssueDate>2011-11-15</cbc:IssueDate>
<cbc:InvoiceTypeCode listAgencyID="320" listID="urn:oioubl:codelist:invoicetypecode-1.1">380</cbc:InvoiceTypeCode>
$file = 'tradeshift_invoice.xml';
if(is_file($file)){
echo 'file exists<br><br>';
}
else{
echo 'file does not exists<br><br>';
}
$xml = simplexml_load_file($file);
//$xml = new SimpleXMLElement(simplexml_load_file($file), 0, true);
echo 'count '.$xml->count().'<br><br>';
foreach($xml->children() as $child){
print_r($child);
}
file exists
count 0
答案 0 :(得分:0)
new SimpleXMLElement仅用于字符串数据,不用于文件。你想使用:
simplexml_load_file($file)
,而不是...
下查找