1. JOSE WILLIAM ROMERO OLIVOS
  2. PowerBuilder
  3. Monday, 10 July 2023 19:04 PM UTC
Cordial Greetings Gentlemen.

I have this xml, and I want to access the data, but it gives me an invalid object error.

What am I doing wrong?

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<FoliosRestantesResponse xmlns="http://tempuri.org/">
<FoliosRestantesResult xmlns:a="http://schemas.datacontract.org/2004/07/ServiceSoap.UBL2._0.Response" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:codigo>200</a:codigo>
<a:foliosRestantes>12</a:foliosRestantes>
<a:mensaje>Se retorna folios restantes.</a:mensaje>
<a:resultado>Procesado</a:resultado>
</FoliosRestantesResult>
</FoliosRestantesResponse>
</s:Body>
</s:Envelope>


Este es el codigo

This is my code to access the data


ls_value = lpbdom_Doc.GetRootElement().GetChildElement("Body", "s","http://schemas.xmlsoap.org/soap/envelope/").&
GetChildElement("FoliosRestantesResponse","","http://tempuri.org/").&
GetChildElement("FoliosRestantesResult","a","http://schemas.datacontract.org/2004/07/ServiceSoap.UBL2._0.Response").&
GetChildElement("codigo","","http://schemas.datacontract.org/2004/07/ServiceSoap.UBL2._0.Response").gettext()

Thanks for your help

error attached




Attachments (1)
JOSE WILLIAM ROMERO OLIVOS Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 13:38 PM UTC
  2. PowerBuilder
  3. # 1
Thank you so much. That is the solution and it worked. Resolved
Comment
  1. Miguel Leeuwe
  2. Tuesday, 11 July 2023 14:19 PM UTC
Great, then please mark "as resolved".
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 11 July 2023 06:04 AM UTC
  2. PowerBuilder
  3. # 2

You shouldn't concatinate statements. It makes it difficult to find errors.

This should work:

lpbdom_element = lpbdom_Doc.GetRootElement()
lpbdom_element = lpbdom_element.GetChildElement("Body", "s","http://schemas.xmlsoap.org/soap/envelope/")
lpbdom_element = lpbdom_element.GetChildElement("FoliosRestantesResponse","","http://tempuri.org/")
lpbdom_element = lpbdom_element.GetChildElement("FoliosRestantesResult","","http://tempuri.org/")
lpbdom_element = lpbdom_element.GetChildElement("codigo","a","http://schemas.datacontract.org/2004/07/ServiceSoap.UBL2._0.Response")
ls_value = lpbdom_element.gettext() 

 

You had two bugs:

<FoliosRestantesResult> inherits the namespace from parent ("http://tempuri.org/")

<codio> needs namespace prefix "a".

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.