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: 
culled
Visitor

XML Parsing Problem

I'm trying to parse a small bit of XML and it isn't working.
xml.ifXMLElement.getName()
gives an error message stating "Member function not found in BrightScript Component or interface". And
xml.ifXMLElement.getText()
prints an empty string. Right now I've got the XML packaged in the application so here's my code to parse the XML:


Function getFeed() As Object
print "Attempting to get the feed"
xmlText = readAsciiFile("pkg:/xml/content.xml")
print "The text is " ; xmlText
xml = createObject("roXMLElement")
if not xml.parse(xmlText)
print "Cannot parse the feed"
return invalid
endif
print "The xml is of type "; type(xml)

print "Name of xml is " ; xml.ifXMLElement.getName()
End Function


It reads the text from the file with no problems and xml.parse() returns true but nothing else seems to work.

The test XML I'm trying to parse is:

<tag>
<other>stuff</other>
</tag>


I know I'm probably making a stupid mistake but I'd be grateful for any help.
0 Kudos
1 REPLY 1
RokuChris
Roku Employee
Roku Employee

Re: XML Parsing Problem

Try it without the ifXMLElement part...

xml.GetName() ' should return "tag"
xml.other[0].GetName() ' should return "other"
xml.other[0].GetText() ' should return "stuff"
0 Kudos