Accessing XML content via PHP using SimpleXML -


I am working with the XML file string below and I have tried several ways to try and get some parts Attempted XML content please try the code after the XML file below for my attempts:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; 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 "& gt; & Lt; Soaps: Body & gt; & Lt; Address_ListResponse xmlns = "http://example.example.com/" & gt; & Lt; Address_ListResult & gt; & Lt; Address & gt; & Lt; Holding ID xsi: nil = "true" /> & Lt; MainId> 1617931 & lt; / MainId> & Lt; ContactId & gt; 8 & lt; / ContactId & gt; & Lt; Details & gt; Home, All Purposes & lt; / Description & gt; & Lt; Status / & gt; & Lt; Department / & gt; & Lt; Organization / & gt; & Lt; Address label & gt; Mr. Joe Blogs & lt; / Address label & gt; & Lt; Address: line 1 & gt; 1 counterfeit road & lt; / Address Line 1 & gt; & Lt; AddressLine2 / & gt; & Lt; AddressLine3 / & gt; & Lt; Town & gt; Faketown & lt; / Town & gt; & Lt; CountyId> 818 & lt; / CountyId> & Lt; PostCode & gt; FA33 4 KE & lt; / PostCode & gt; & Lt; CountryID & gt; 3 & lt; / CountryID & gt; & Lt; Phone & gt; 01234567890 & lt; / Phone & gt; & Lt; EvePhone / & gt; & Lt; Mobile /> & Lt; Email & gt; Joe@bloggs.com< / Email & gt; & Lt; Fax / & gt; & Lt; WWW / & gt; & Lt; AddressTypeId & gt; 1 & lt; / AddressTypeId> & Lt; IsBilling & gt; True & lt; / IsBilling & gt; & Lt; IsMailing & gt; True & lt; / IsMailing & gt; & Lt; IsDelivery & gt; True & lt; / IsDelivery & gt; & Lt; IsInherited & gt; False & lt; / IsInherited & gt; & Lt; GridN / & gt; & Lt; Variable-variable / & gt; & Lt; Latitude / & gt; & Lt; Longitude / & gt; & Lt; CensationCode / & gt; & Lt; IsDeleted & gt; False & lt; / IsDeleted & gt; & Lt; Holdingpersonal detail id xsi: nil = "true" /> & Lt; IsSynced & gt; False & lt; / IsSynced & gt; & Lt; BeenProcessed & gt; False & lt; / BeenProcessed & gt; & Lt; CountyName / & gt; & Lt; COUNTRYNAME / & gt; & Lt; AddressTypeName & gt; Home & lt; / AddressTypeName & gt; & Lt; / Address & gt; & Lt; / Address_ListResult & gt; & Lt; / Address_ListResponse & gt; & Lt; / Soap: Body & gt; & Lt; / Soap: Envelope & gt;  

Code to access XML content:

  $ xml = simplexml_load_string ($ result); Echo "city:" $ xml-> Children ('http://schemas.xmlsoap.org/soaf/envelope/') - & gt; Children ('http://example.example.com/') - & gt; Address_ListResponse- & gt; Town;  

The above code was based on the link posted by another stack overflow question:

Any help would be appreciated.

Thank you.

Consider using instead.
See how to write a client.

An option will be used as a standalone component.


Comments