Stephen,

thanks so much! That was really useful. I looked to the LR and found out there was nothing about XmlNamespaces, weird?!

Anyway I found an old post of yours in the forum, modified the code you made to automatically retrieve all namespaces. I retrieve it via string+regex as GetAttributeNode still skips the first attribute.

after xdoc.LoadXml(...) just put getNameSpaces(xdoc)

Private Sub getNameSpaces(xml as XMLDocument)
  Dim root as XmlNode
  Dim nl as XmlNodeList
  Dim i as integer
  Dim attribute as XmlAttribute
  Dim rsstxt as string
  Dim r as New RegEx
  Dim myMatch as RegExMatch
  Dim sr,value,name as string


  nsmap=New XmlNamespaces

  nl=xml.Xql("rss")

  if nl.Length>0 then
    rsstxt = nl.Item(0).ToString

    r.Options.Greedy = False
    r.SearchPattern="xmlns.+=.+"""

    myMatch=r.Search(rsstxt)
    While myMatch <> nil
      sr=myMatch.SubExpressionString(0)

      value=NthField(sr,"""",2)
      name=NthField(sr,"=",1)
      name=NthField(name,":",2)

      nsmap.Uri(name)=value

      myMatch=r.Search
    Wend
  end if
End Sub

nsmap has to be a global that will be used in .xql queries. In my case I do all the parsing with a class so it's not a problem to have this global around.

HTH someone else.

Cheers,
Tomas

dim nsmap as new XmlNamespaces
dim n as XmlNodeList

nsmap.Uri("feedburner") = "http://rssnamespace.org/feedburner/ext/1.0";
nsmap.Uri("itunes") = "http://www.itunes.com/DTDs/Podcast-1.0.dtd";

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to