Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
nanuto
Level 7

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
EnTerr
Level 8

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
Level 7

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 Smiley Happy.
0 Kudos