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

how to tell if xml element is present vs empty

I need to read a bit of XML and determine if a given xml node is present. If it is present, even if it doesnt have any children, I need to do one set of actions. If it just isnt present I need do something else. I tried testing it against invalid and checking its type() but they don't provide a way to distinguish. The element is not listed as invalid when its not present and it's type() is listed as roXMLList even though it doesn't exist

How can I tell if an XML element is present or not?
0 Kudos
1 REPLY 1
TheEndless
Channel Surfer

Re: how to tell if xml element is present vs empty

If xml.NonExistentNode.Count() = 0 Then
' node doesn't exist
End If
If xml.NodeWithChildren.GetChildElements().Count() > 0 Then
' node has children
End If
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