I do a SOAP-call to my client. It returns a XML-document as a string (this is a workaround that I can’t do anything about). I have the XML in a variable and I need to read this XML to grab the information I want.
I am looking for the fields DomesticCustomer, Addresses and GridOwner. I guess if someone helps me to get to the DomesticCustomer-part I can do the rest on my own.
Note: In this example, there is only one entry under each field, but there could be multiple, so I need to be able to foreach this.
Note #2: Because the client I use has some weird workaround for this to work, the response (the xml) is a simple string.
The XML is:
<?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">
<soap:Body>
<MeteringPointIdResponse xmlns="http://www.ediel.no/schemas/public/nubix/MeteringPointIdResponse">
<RequestId xmlns="">3423424234</RequestId>
<Requestor xmlns="">
<GLN>234234234</GLN>
</Requestor>
<Customers xmlns="">
<DomesticCustomer>
<LastName>Name</LastName>
<FirstName>Name</FirstName>
<BirthDate>xxx-xx-xx</BirthDate>
<MeterNumber>xxxxx</MeterNumber>
<Addresses>
<Address>
<Address1>345345</Address1>
<PostCode>3514</PostCode>
<Location>xxxxxx</Location>
<CountryCode>xx</CountryCode>
<Installation>
<Description>xxxxx</Description>
<MeteringPointId>xxxxxxxxxxxxxxx</MeteringPointId>
<MeteringMethod>xxxxxx</MeteringMethod>
<InstallationStatus>xxxx</InstallationStatus>
<LastReadOffDate>xxxx-xx-xx</LastReadOffDate>
</Installation>
<GridOwner>
<GLN>xxxxxxx</GLN>
<Name>xxxxxxxx</Name>
<ProdatAddress>
<InterchangeRecipient>
<Id>xxxxxxx</Id>
<Qualifier>xx</Qualifier>
<Subaddress>xxxxx</Subaddress>
</InterchangeRecipient>
<Party>
<Id>xxxxxxxxxx</Id>
<CodeListResponsible>xxxx</CodeListResponsible>
</Party>
<EDISyntax>
<CharSet>xxx</CharSet>
<SyntaxId>xxxx</SyntaxId>
</EDISyntax>
<SMTPAddress>test@hey.com</SMTPAddress>
</ProdatAddress>
</GridOwner>
</Address>
</Addresses>
</DomesticCustomer>
</Customers>
</MeteringPointIdResponse>
</soap:Body>
</soap:Envelope>
If you use the built in library for php, it parses the response and returns a mixed object/array object that is INFINITELY easier to deal with than the xml
Edit: since you are using php’s built in client, here is a simple class that I wrote built around it. It “flattens” the responce and makes it easy to retrieve responces like:
}