Forum Discussion

3 Replies

  • I'm not sure what you mean by "weird thing" but...

    The part before the colon (media) is the namespace as defined by the "xmlns:media" attribute. It's essentially a way of making a common tag name unique, and associate it with a specific data source. I haven't parsed an XML document with namespaces in BrightScript, but I'd think you would be able to get it with GetNamedElements().

    The values I think you're talking about (url, width, and height) are attribute values. You'd access them using @. (ex. xmlElement@url, xmlElement@width, etc). There are examples in the "working with XML" section of the BrightScript reference.
  • "jbrave" wrote:
    Anyone know how to get and parse an xml tag that has a colon in it like this:

    <media:thumbnail xmlns:media='http://something.something.com/mrss/' url='http://blahblablah.com' width='72' height='72' />


    • To access elements with namespaces, use elementArray = GetNamedElements("media:thumbnail")

    • To access attributes without namespaces, you can use the @ operator. element@url

    • For attributes with namespaces, you would need to say element.GetAttributes()["xmlns:media"]
  • jbrave's avatar
    jbrave
    Channel Surfer
    By weird I meant I hadn't encountered this style of before in the parsing projects I've undertaken. Anyway, got it working using GetNamedElements("media:thumbnail") and then GetAttributes()

    Thanks!

    - Joel