Ah,now it makes more sense.

Am I missing something?

Yes you are, but it isn't really your fault.  XML namespaces and
especially how they need to be treated with XPath is not exactly what i
would call intuitive. And this really isn't an RB thing.  Its just as
confusing in .Net or anywhere else.

XML engines must always know what the URI is for the namespace prefix. When it exists in the document, like it does with your cnn example, all is well. When it doesn't exist, the xml engine barfs up a hairball. So the way most popular engines deal with that is they allow you to pass a namespace map along with your query. You need to define any namespace URIs that you might use in your query. You don't need them for the tags in the document, since they will be defined in the doc. You just need to specify the ones you use in your query in case they don't exist in the document. The engine can use your map as how to define the prefixes.

So in your case, do something like:

----
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";

try
   n=node.Xql(value, nsmap)
Catch
   return ""
end try

----

Now if your source documents dont have a tag that uses itunes: or feedburner: prefixes, you will simply get a 0 length nodelist. The reason you are getting the exception is that any xml document (or XPath query) that doesn't define a uri for a prefix can't be parsed.

I hope this helps.

-stephen
_______________________________________________
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