Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nanuto
Visitor

XML function Parse

Hi, this my function

Function login()

searchRequest=CreateObject("roUrlTransfer")
searchRequest.SetURL(host() + "?xid=start")
result = searchRequest.GetToString()
return result


i call it as print login() the debuger looks like...from the request to my host,


<?xml version='1.0' encoding='iso-8859-1'?>
<User>
<Rcode>text</Rcode>
<Uname>username</Uname>
<Status>Hi im active.</Status>
</User>


but wow can i access to the elements. i try this way,
myxml = login()
list = CreateObject("roXMLElement")
list.Parse(myxml)
print list.user.Uname.GetText()
print list.Uname.GetText()


Thank for the help.
0 Kudos
2 REPLIES 2
EnTerr
Roku Guru

Re: XML function Parse

<User> is the root element, so filter w/o it:

BrightScript Debugger> xml = createObject("roXmlElement")
BrightScript Debugger> ? xml.parse("<User><Rcode>text</Rcode><Uname>username</Uname><Status>Hi im active.</Status></User>")
true
BrightScript Debugger> ? xml.Uname.getText()
username
0 Kudos
nanuto
Visitor

Re: XML function Parse

Thanks thats worked!,
another solution that i share

root = xml.getChildElements()
Status_e = xml.getNamedElements("Status")
Status = Status_e[0].gettext()


Thank you :).
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.