revXMLNodeContents

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

revXMLNodeContents

Post by CElwell » Wed Mar 16, 2016 6:13 pm

I am trying to display "Species" in the text box below, however, I keep getting an XML error. I am not sure why as I believe I have the correct pathway. Is there something I am missing? Help is greatly appreciated!!! Thank you!!!
Attachments
1.png
Here is a screenshot of my code and what occurs on the app screen.

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: revXMLNodeContents

Post by LCNeil » Mon Mar 21, 2016 12:48 pm

Hi Cassidy,

Where are you setting X in your revXMLNodeContents script?

I was able to script the following an the string "dog" was returned as expected (ommiting my auth key)-

Code: Select all

on mouseUp
   put url "http://www.petango.com/WebServices/wsAdoption.asmx/AdoptableSearch?authkey=**AUTHKEYHERE**&speciesID=&sex=F&ageGroup=&location=&site=&onHold=&orderBy=&primaryBreed=&secondaryBreed=&specialNeeds=&noDogs=&noCats=&noKids=Y&stageID=" into tURL
   put revXMLCreateTree(tURL,true,true,flase) into tData
   put revXMLNodeContents(tData, "ArrayOfXmlNode/XmlNode/adoptableSearch/Species") into tSpecies
   put tSpecies
end mouseUp
Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--

CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

Re: revXMLNodeContents

Post by CElwell » Mon Mar 21, 2016 10:08 pm

LCNeil wrote:
Where are you setting X in your revXMLNodeContents script?

--
I set the url into x, but looking at your code I believe my problem may have been that for putrevXMLNodeContents I wasn't using the "field" used above for the tree. So that worked, but now I am trying to extract "Species" from all of the "XmlNode"s and did research finding repeat is a good method. I am getting the same error again though--is this because I am not using revXMLChildNames correctly?

Also--a basic question--how can I set my "tInfo" as an output so that the data extracted is shown in "tInfo" rather than coming up in the message center?

Thank you!!!!!!
Cassidy
Attachments
test.png
Code using repeat

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: revXMLNodeContents

Post by LCNeil » Wed Mar 30, 2016 2:51 pm

Hi Cassidy,

I would look into converting the XML data to a LiveCode array as this would make it a bit easier to work with within LiveCode. The good news is that there is a stack available that takes care of this for you-

http://livecodeshare.runrev.com/stack/571/XMLAndArrays

In regards to the message box showing the XML data, you have to put this variable into something (e.g a field, datagrid etc) as if "Put" is used on its own, the data is simply placed in the message box (great for debugging purposes).

So in my example, I would need to change

Code: Select all

put tSpecies
to something like

Code: Select all

 put tSpecies into field "data"
if I did not want it to show in the message box.

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm
Location: Greece

Re: revXMLNodeContents

Post by zaxos » Fri Apr 08, 2016 3:17 pm

Code: Select all

on mouseUp
   put url "http://www.petango.com/webservices/wsadoption.asmx/AdoptableSearch?authkey={AUTHKEY}&speciesID=&sex=&ageGroup=&location=&site=&onHold=&orderBy=&primaryBreed=&secondaryBreed=&specialNeeds=&noDogs=&noCats=&noKids=&stageID=" into  tURL
   put revCreateXMLTree( tURL, true, true, false) into tInfo
   put revXMLChildNames( tInfo, "ArrayOfXmlNode", return, "XmlNode", true) into tChildren -- "XmlNode" = Correct , "XmlNode/adoptableSearch" = incorect, should only use 1 level
   repeat for each line tChild in tChildren
      add 1 to x
      put revXMLChildNames( tInfo, "ArrayOfXmlNode/"&tChild&backslash, return, "adoptableSearch", true) into tAdoptable -- most of the times theirs just 1 node in here but you could add 1 more repeat in case there are more
      --put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/adoptableSearch[1]/ID") & comma after tData -- ID
      put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/"&tAdoptable&"/Name") & comma after tData -- Name
      put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/"&tAdoptable&"/Species") & comma after tData -- Species
      put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/"&tAdoptable&"/Sex") & comma after tData -- Sex
      put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/"&tAdoptable&"/PrimaryBreed") & comma after tData -- PrimaryBreed
      put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/"&tAdoptable&"/SecondaryBreed") & comma after tData -- SecondaryBreen
      --put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/adoptableSearch[1]/SN") & comma after tData -- SN
      put revXMLNodeContents( tInfo, "ArrayOfXmlNode/"&tChild&"/"&tAdoptable&"/Age") after tData -- Age
      put return after tData
   end repeat
   
   put tData// & return after tOutput
   //set the text of field "Species" to tOutput
end mouseUp
It should be straight forward from here how to get the photos too, let me know if you need help.
Knowledge is meant to be shared.

Post Reply

Return to “Databases”