revXMLNodeContents
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
revXMLNodeContents
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!!!
Re: revXMLNodeContents
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)-
Kind Regards,
Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--
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
Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--
Re: revXMLNodeContents
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?LCNeil wrote:
Where are you setting X in your revXMLNodeContents script?
--
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
Re: revXMLNodeContents
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 to something like if I did not want it to show in the message box.
Kind Regards,
Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--
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
Code: Select all
put tSpecies into field "data"
Kind Regards,
Neil Roger
--
LiveCode Support Team ~ http://www.livecode.com
--
Re: revXMLNodeContents
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
Knowledge is meant to be shared.