-1

I have a problem with PHP. I cannot read xml with PHP, and with SimpleXml. How can I do.

My Xml files is below. I just want your CompanyList.

<?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>
Caner
  • 813
  • 1
  • 12
  • 26

1 Answers1

0
$dom = new DOMDocument;
$dom->loadXML($response);
$books = $dom->getElementsByTagName('Identifier');
foreach ($books as $book) {
    echo $book->nodeValue ."</br>";
}
Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
Caner
  • 813
  • 1
  • 12
  • 26
  • While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please [include an explanation for your code](//meta.stackexchange.com/q/114762/269535), as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. **Flaggers / reviewers:** [For code-only answers such as this one, downvote, don't delete!](//meta.stackoverflow.com/a/260413/2747593) – Scott Weldon Nov 17 '16 at 18:14