XML parsing and revXMLNodeContents

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

XML parsing and revXMLNodeContents

Post by garyth123 » Wed Jun 19, 2013 3:26 pm

Hi,

Suppose I have some data

<XMLSOCCER>
<Team>
<Team_Id>45</Team_Id>
<Name>Aberdeen</Name>
<Country>Scotland</Country>
<Stadium>Pittodrie Stadium</Stadium>
<HomePageURL>www.afc.co.uk</HomePageURL>
<WIKILink>http://en.wikipedia.org/wiki/Aberdeen_F.C.</WIKILink>
</Team>
...
</XMLSOCCER>

and I want to use revXMLNodeContents to get the Name of a Team.

I haven't been able to extract this info and it is driving me a bit nuts as I'm not clear what I'm doing wrong. I have for instance tried

put revCreateXMLTree(tResponse, false, true, false) into tDocID
put revXMLNodeContents(tDocID,"XMLSOCCER/Team_Id/Name") into tResult

and
put revCreateXMLTree(tResponse, false, true, false) into tDocID
put revXMLNodeContents(tDocID,"/XMLSOCCER/Team_Id/Name") into tResult

but I always get an xmlerr can't find element.

Can anyone give any further info (obviously I've consulted the Docs) on how this command should be used.

Thanks in advance.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: XML parsing and revXMLNodeContents

Post by Klaus » Wed Jun 19, 2013 3:36 pm

Hi garyth,

shouldn't this be "Team" without "_Id":
...
put revXMLNodeContents(tDocID,"XMLSOCCER/Team/Name") into tResult
...


Best

Klaus

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: XML parsing and revXMLNodeContents

Post by garyth123 » Wed Jun 19, 2013 3:47 pm

Klaus wrote:Hi garyth,

shouldn't this be "Team" without "_Id":
...
put revXMLNodeContents(tDocID,"XMLSOCCER/Team/Name") into tResult
...


Best

Klaus
Hi Klaus,

Thanks for spotting the above error but what I've put above is a typo or an error from copying over my code and then editing in the forum entry. I have tried eg

put revXMLNodeContents(tDocID,"/XMLSOCCER/Team/Name") into tResult

and as I say I keep getting an xmlerr, can't find element.

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: XML parsing and revXMLNodeContents

Post by garyth123 » Wed Jun 19, 2013 3:58 pm

Thanks Klaus, your post has helped me now to see my mistake.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: XML parsing and revXMLNodeContents

Post by Klaus » Wed Jun 19, 2013 4:26 pm

And what was it?

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: XML parsing and revXMLNodeContents

Post by garyth123 » Wed Jun 19, 2013 5:03 pm

Klaus wrote:And what was it?
I didn't get that for the required path you would put /root/node/child_2 say but thought it would have to include all prior child nodes so /root/node/child_1/child_2. Of course now I feel a bit silly.

Thanks again for responding and pointing out the obvious to me.

garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Re: XML parsing and revXMLNodeContents

Post by garyth123 » Wed Jun 19, 2013 6:52 pm

Now discovering that I can make use of some of the other revXML commands that better suit my purpose.

Post Reply