Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用PHP读取Xml节点_Php_Simplexml_Readxml - Fatal编程技术网

用PHP读取Xml节点

用PHP读取Xml节点,php,simplexml,readxml,Php,Simplexml,Readxml,我对PHP有一个问题。我不能用PHP和SimpleXml读取xml。 我该怎么办 下面是我的Xml文件。 我只想要你的公司名单 <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="htt

我对PHP有一个问题。我不能用PHP和SimpleXml读取xml。 我该怎么办

下面是我的Xml文件。 我只想要你的公司名单

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  <soap:Header>
    <wsa:Action>http://www.temp/Response</wsa:Action>
    <wsa:MessageID>urn:uuid:eac190a5-c833-4dee-b4ef-fa81b0bad5c1</wsa:MessageID>
    <wsa:RelatesTo>urn:uuid:834ace07-1e96-49d9-b958-3b2b87169917</wsa:RelatesTo>
    <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
    <wsse:Security>
      <wsu:Timestamp wsu:Id="Timestamp-55f3bafa-087a-4971-975d-a314957b4282">
        <wsu:Created>2016-11-17T15:12:46Z</wsu:Created>
        <wsu:Expires>2016-11-17T15:17:46Z</wsu:Expires>
      </wsu:Timestamp>
    </wsse:Security>
  </soap:Header>
  <soap:Body>
    <ListResponse xmlns="http://fatura.edoksis.net">
      <CompanyResult>
        <Success>1</Sonuc>
        <CompanyList>
          <Company>
            <Identifier>8380436088</Identifier>
            <RegisterTime>2016-10-21T00:00:00Z</RegisterTime>
          </Company>
          <Company>
            <Identifier>8380436088</Identifier>
            <RegisterTime>2016-10-21T00:00:00Z</RegisterTime>
          </Company>
        </CompanyList>
      </CompanyResult>
    </CompanyResult>
  </soap:Body>
</soap:Envelope>

http://www.temp/Response
urn:uuid:eac190a5-c833-4dee-b4ef-fa81b0bad5c1
urn:uuid:834ace07-1e96-49d9-b958-3B28169917
http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
2016-11-17T15:12:46Z
2016-11-17T15:17:46Z
1.
8380436088
2016-10-21T00:00:00Z
8380436088
2016-10-21T00:00:00Z
$dom=新的DOMDocument;
$dom->loadXML($response);
$books=$dom->getElementsByTagName('Identifier');
foreach($books作为$book){
echo$book->nodeValue。“
”; }
我正在尝试。虽然这个代码片段可以解决这个问题,但它没有解释为什么或者如何回答这个问题。请,因为这确实有助于提高你的文章质量。请记住,您将在将来回答读者的问题,这些人可能不知道您的代码建议的原因。标记者/审阅者:
$dom = new DOMDocument;
$dom->loadXML($response);
$books = $dom->getElementsByTagName('Identifier');
foreach ($books as $book) {
    echo $book->nodeValue ."</br>";
}