Page 1 of 1

Parsing XML - xmlerr, bad document id

Posted: Thu Aug 10, 2017 11:30 am
by williamsc84
Hello there, this is only my 2nd post to the forums, I am new to LiveCode and coding in general.

Also because this is only my 2nd post I could not post URL's so I have put all of my code i refer to in this post inside a sample livecode stack.

The app I am trying to build sends a request to a SOAP web service and returns XML data, I am trying to parse that XML data.

To begin with I have been following the lesson "How to read in data from an XML file" on the LiveCode Lessons website.

I replaced the sample XML file in this lesson with the XML data shown in the attached sample file (The XML is included in the bottom field - note in my actual app this is located in a file called preferences.xml - just like the lesson suggests)

Then following the lesson, and some assumptions I was making, I edited the code for parsing the XML to suit my XML file. ( the code for this is included on the button in my sample file )

In my live app when I press the button, I get this error "xmlerr, bad document id"

I am hoping someone can spot what I am clearly doing wrong and help point me in the right direction

Thanks in advance for taking the time to look at this

Re: Parsing XML - xmlerr, bad document id

Posted: Thu Aug 10, 2017 11:56 am
by Klaus
Hi William,

you passed a param named pTree to your private command, but you do not use it in the handler:

Code: Select all

private command processPreferencesTree pTree  
   local tStd
   ## put revXMLNodeContents(tTreeID, "/Envelope/Body/GetDepartureBoardResponse/GetStationBoardResult/trainServices/service/std") into tStd
   put revXMLNodeContents(pTree, "/Envelope/Body/GetDepartureBoardResponse/GetStationBoardResult/trainServices/service/std") into tStd
...
Hint: Next train at: 12:29 :D

Best

Klaus

Re: Parsing XML - xmlerr, bad document id

Posted: Thu Aug 10, 2017 11:58 am
by Klaus
Oh, and welcome to the forum! :D

Re: Parsing XML - xmlerr, bad document id

Posted: Fri Aug 11, 2017 1:37 pm
by williamsc84
Amazing thank you. That works perfectly.

Thank you for taking the time to get back to me and explaining where I went wrong. It's much appreciated.