php - How to obtain an orphan boolean xml value from a string -


I am working with an API which is returning some XML data which I am unable to get.

When a login succeeds, the session key is authenticated and the API returns the Boolean value to 'true'.

It is formatted as follows:

  This XML file does not contain any style associated with it. The document tree is shown below & lt; Boolean xmlns = "http://tessiturasoftware.com/" & gt; True & lt; / Booolan & gt;  

Where other XML data is formatted with nested structure, I am using the following PHP to extract data

  $ prodresponse = Curl_exac ($ getproductions); If (curl_errno ($ getproductions)) {echo 'curl error: unable to get session ID' curl_error ($ getproductions); } And {$ xmlContent = simplexml_load_string ($ prodresponse); Echo $ prodresponse; Foreign currency ($ xmlContent-> xpath ('// production') as $ prod) {$ prodid = $ prod-> Prod_season_no; Echo "& form; form action = 'GetProductionDetail.php' method = 'GET' & gt;"; Input type = 'hidden' name = 'supplied' & amp; Type; & Lt; H1 & gt; "$ Prod-> prod_desc." & Lt; / H1> & Lt; Input type = 'submit' value = 'book now' value = $ prodid / & gt; & Lt; / Form & gt; "}}  

But when I try to use the following to return the boolean value and go to the account details page, no data returns < / P>

  $ response2 = curl_xac ($ login); $ XmlContent = simplexml_load_string ($ response2); if (curl_errno ($ login)) {echo 'curl error: unable to login' curl_error ($ Entry);} Else {echo 'test'; foreign currency ($ xmlContent-> xpath ('boolean') as $ bool) {echo $ bool; resonance 'test';} ($ bool == ' S ') {Echo'test'; Header ("Location: GetAccountDetails.php")}}  

Can someone please tell me whether I am doing something wrong, whether it is simplexml_load_string Or will it help to create a simple XMLML object ...?

Thanks

Caspian

If there is a namespace definition in XML, then the element's "real / internal" name is {http://tessiturasoftware.com/}: boolean . To bring this element without ignoring the namespace, you have to register a prefix for it. In Simplex, for that method, registerXpathNamespace () after that you can use the prefix as the nickname for the namespace string. If you register tess , then the element can be addressed as tess: boolean .

I like DOM because it allows me to more complex Xpath, such as with casting result string and compare it.

  $ dom = newdomdocument (); $ Dom- & gt; Load xml ('& lt; boolean xmlns = "http://tessiturasoftware.com/" & gt; true & lt; / booolan & gt;';); $ Xpath = new DOMXpath ($ dom); $ Xpath- & gt; Register Namespace ('Tess', 'http://tessiturasoftware.com/'); Var_dump ($ xpath-> Evaluate ('string (/ tes: boolean) = "true"'));  

Program output

  bool (true)  

Comments