I'm having difficult parsing a simpleXml string to get a value out. I've tried
To get the creationdatetime field, but this is not returning anything for me. I'm familiar with parsing simple xml, but the namespaced xml throws me difficulty, especially because all examples always have namespaced xml embedded, rather than the whole thing being namespaced.Code:$xml = new SimpleXmlElement($simpleXml); $xml->registerXPathNamespace("ns0", "http://www.openapplications.org/oagis"); foreach($xml->xpath('//ns0:applicationarea/a:sender') as $n) { echo $n->creationdatetime . "success"; }
Code:<ns0:syncparty xmlns:ns0="http://www.openapplications.org/oagis" revision="1.0" environment="Production" lang="en-US"> <ns0:applicationarea> <ns0:sender> <ns0:authorizationid>QPIM</ns0:authorizationid> </ns0:sender> <ns0:creationdatetime>2012-11-12T09:58:32.257-08:00</ns0:creationdatetime> </ns0:applicationarea> <ns0:dataarea> <ns0:sync> <ns0:synccriteria expressionlanguage="XPath"> <ns0:syncexpression action="Sync">GetContact</ns0:syncexpression> </ns0:synccriteria> </ns0:sync> <ns0:party active="false" onetime="false"> <ns0:contacts> <ns0:primarycontact> <ns0:person> <ns0:personcode>409090</ns0:personcode> <ns0:personname> <ns0:givenname>Erik</ns0:givenname> <ns0:familyname>Sparrow</ns0:familyname> <ns0:userarea> </ns0:userarea></ns0:personname> <ns0:userarea> </ns0:userarea></ns0:person> <ns0:qctelex> <ns0:emailaddress>artest02@qcomtest.com</ns0:emailaddress> <ns0:addresses> <ns0:primaryaddress> <ns0:country>UNITED STATES</ns0:country> <ns0:qccountrycode> <ns0:qcccode>US</ns0:qcccode> </ns0:qccountrycode> <ns0:userarea> </ns0:userarea></ns0:primaryaddress> </ns0:addresses> <ns0:userarea> <ns0:property> <ns0:namevalue name="reg_id">172914</ns0:namevalue> <ns0:description>QPIM Registration Id</ns0:description> </ns0:property> <ns0:property> <ns0:namevalue name="qcOldDN">N/A</ns0:namevalue> <ns0:description>QPIM Rename Values</ns0:description> </ns0:property> <ns0:useraccount> <ns0:systemid>artest02@qcomtest.com</ns0:systemid> <ns0:authorization> <ns0:id>422</ns0:id> <ns0:type>bus_role</ns0:type> <ns0:status> <ns0:code>A</ns0:code> <ns0:change> <ns0:changedate>2012-02-06T11:20:34-08:00</ns0:changedate> <ns0:userarea> <ns0:property> <ns0:namevalue name="UPDATED_BY">QPIM</ns0:namevalue> </ns0:property> </ns0:userarea> </ns0:change> </ns0:status> <ns0:dateauthorized>2012-02-06T11:20:34-08:00</ns0:dateauthorized> <ns0:authorizationcode>CRD_AR</ns0:authorizationcode> <ns0:userarea> <ns0:property> <ns0:namevalue name="CREATED_BY">QPIM</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="DESCRIPTION">Provisioning Role for CRD_AR</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="TAG">ar</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="OWNER_ID">484</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="OWNER_NAME">CRD_Admins</ns0:namevalue> </ns0:property> </ns0:userarea> </ns0:authorization> <ns0:authorization> <ns0:id>402</ns0:id> <ns0:type>bus_role</ns0:type> <ns0:status> <ns0:code>A</ns0:code> <ns0:change> <ns0:changedate>2012-07-18T13:55:41-07:00</ns0:changedate> <ns0:userarea> <ns0:property> <ns0:namevalue name="UPDATED_BY">arsrvc</ns0:namevalue> </ns0:property> </ns0:userarea> </ns0:change> </ns0:status> <ns0:dateauthorized>2012-07-18T13:55:41-07:00</ns0:dateauthorized> <ns0:authorizationcode>CRD_Alpha</ns0:authorizationcode> <ns0:userarea> <ns0:property> <ns0:namevalue name="CREATED_BY">arsrvc</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="DESCRIPTION">Provisioning role for CRD_ALPHA</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="TAG">alpha</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="OWNER_ID">484</ns0:namevalue> </ns0:property> <ns0:property> <ns0:namevalue name="OWNER_NAME">CRD_Admins</ns0:namevalue> </ns0:property> </ns0:userarea> </ns0:authorization> <ns0:authorization> <ns0:id>22</ns0:id> <ns0:type>policy_role</ns0:type> <ns0:status> <ns0:code>A</ns0:code> <ns0:description>Approved</ns0:description> <ns0:change> <ns0:changedate>2012-02-06T11:20:43-08:00</ns0:changedate> <ns0:userarea> <ns0:property> <ns0:namevalue name="UPDATED_BY">QPIM_VALID_DPL</ns0:namevalue> </ns0:property> </ns0:userarea> </ns0:change> </ns0:status> <ns0:dateauthorized>2012-02-06T11:20:34-08:00</ns0:dateauthorized> <ns0:authorizationcode>QPIM_VALID_DPL</ns0:authorizationcode> <ns0:userarea> <ns0:property> <ns0:namevalue name="CREATED_BY">QPIM</ns0:namevalue> </ns0:property> <ns0:property> TRUNCATED </ns0:syncparty>


Reply With Quote

Bookmarks