Parsing XML - xmlerr, bad document id

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
williamsc84
Posts: 7
Joined: Sun Aug 06, 2017 1:54 pm

Parsing XML - xmlerr, bad document id

Post by williamsc84 » Thu Aug 10, 2017 11:30 am

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
Attachments
samplecode.livecode.zip
The parsing code is on the button in this stack and the sample XML file I am trying to parse I have just put into a field on the bottom of this stack. In my actual app this is in a file called preferences.xml as per the lesson
(2.8 KiB) Downloaded 59 times

Klaus
Posts: 12285
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Parsing XML - xmlerr, bad document id

Post by Klaus » Thu Aug 10, 2017 11:56 am

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

Klaus
Posts: 12285
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Parsing XML - xmlerr, bad document id

Post by Klaus » Thu Aug 10, 2017 11:58 am

Oh, and welcome to the forum! :D

williamsc84
Posts: 7
Joined: Sun Aug 06, 2017 1:54 pm

Re: Parsing XML - xmlerr, bad document id

Post by williamsc84 » Fri Aug 11, 2017 1:37 pm

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”