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

Parsing XML with hyphen in node name?

Is it possible to parse XML when a node has a hyphen in the name?

for example:

<?xml version="1.0" encoding="UTF-8"?>
<device>
<id type="integer">6</id>
<product>Roku</product>
<product-id>123abc</product-id>
<auth-token>TKMWhuagCU9C6f68u76ryw</auth-token>
<user-id type="integer">2</user-id>
<created-at type="datetime">2011-12-28T18:54:36Z</created-at>
<updated-at type="datetime">2011-12-28T18:54:36Z</updated-at>
</device>


If I create a <Component: roXMLElement> from this body as the variable "xml" I get the following:


BrightScript Debugger> print xml.id.GetText()
6
BrightScript Debugger> print xml.auth-token.GetText()
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in $LIVECOMPILE(32)
0 Kudos
2 REPLIES 2
TheEndless
Channel Surfer

Re: Parsing XML with hyphen in node name?

You need to use xml.GetNamedElements("auth-token") to access nodes with special characters in their name.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
bmckim
Visitor

Re: Parsing XML with hyphen in node name?

Thanks, will give it a try.
0 Kudos