nanuto
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2015
01:42 AM
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.
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.
2 REPLIES 2
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2015
11:17 AM
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
nanuto
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2015
05:21 PM
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 :).
another solution that i share
root = xml.getChildElements()
Status_e = xml.getNamedElements("Status")
Status = Status_e[0].gettext()
Thank you :).