Search Results

Search found 1 results on 1 pages for 'user1291894'.

Page 1/1 | 1 

  • use simplexml to get attributes of elements

    - by user1291894
    I am trying to parse an xml file with a soap envelope from a web service using php. I would like to use SoapClient, but I get an error back that 'page must be viewed over secure channel SSL', which I think is an issue on their end, so I gave up on that. Currently I am using curl to get a result back. Then I put it into a simplexml object like so: <?php $xml = @simplexml_load_string($result, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/"); $xml->registerXPathNamespace('xs', 'http://www.w3.org/2001/XMLSchema'); $output = $xml->xpath('//soap:Body'); ?> I now have this: Array ( [0] => SimpleXMLElement Object ( [GetDocumentListResponse] => SimpleXMLElement Object ( [GetDocumentListResult] => <NewDataSet> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="_x0023_temp_list"> <xs:complexType> <xs:attribute name="tran_datetime" type="xs:string" /> <xs:attribute name="sender" type="xs:string" /> <xs:attribute name="doc_type_num" type="xs:string" /> <xs:attribute name="doc_date" type="xs:string" /> <xs:attribute name="doc_num" type="xs:string" /> <xs:attribute name="doc_sys_no" type="xs:string" /> <xs:attribute name="is_new" type="xs:string" /> </xs:complexType> </xs:element> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="_x0023_temp_list" /> </xs:choice> </xs:complexType> </xs:element> </xs:schema> <_x0023_temp_list tran_datetime="2012-03-22T13:37:17.237" sender="webservice" doc_type_num="100" doc_date="2012-03-22T13:37:17.253" doc_num="12345" doc_sys_no="1234567" is_new="1" /> </NewDataSet> ) ) ) I am able to loop through this object and get to the part between the "NewDataSet" tags, but I can't seem to get to the individual elements. What I need is the attributes in the last tag that starts with _x0023_temp_list. I'm not sure if the tag is always going to be named that, so I will probably also have to deal with getting attributes from the tag with the xs namespace as well. I've read quite a few other posts and have tried several different methods of getting the info and so far nothing has seemed to work.

    Read the article

1