Thank Pat, I just tried that, now I get the same error:
{"Namespace Manager or XsltContext needed. This query has a prefix,
variable, or user-defined function."}
Here is my code
Dim sXML as string="http://www.weather.gov/alerts/al.cap"
Dim xDoc As New XmlDocument()
Dim nNode As XmlNode
Dim nNodes As XmlNodeList
xDoc.NameTable.Add("cap")
Dim ns As XmlNamespaceManager = New XmlNamespaceManager(xDoc.NameTable)
ns.AddNamespace("cap", "http://www.incident.com/cap/1.0")
xDoc.LoadXml(sXML)
'THIS IS THE :INE THAT CRASHES
nNode = xDoc.SelectSingleNode("cap:alert")
If Not nNode Is Nothing Then
nNodes = nNode.SelectNodes("cap:info")
If Not nNodes Is Nothing Then
Debug.Print(nNodes.Count.ToString)
End If
End If
"Patrick Steele" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In article <(E-Mail Removed)>,
> (E-Mail Removed) says...
>> I have a app that gets xml data from a web site using http:
>> This all works if I test it in VB6, but the ParseXMLFile function
>> crashes on the line:
>> nNode = xDoc.SelectSingleNode("cap:alert")
>> With the error message
>> "Namespace Manager or XsltContext needed. This query has a prefix,
>> variable,
>> or user-defined function."
>
> You need to add the defined "cap" namespace to the XmlDocument object.
> Something like this should work:
>
> xDoc.NameTable.Add("cap")
> Dim ns As XmlNamespaceManager = new XmlNamespaceManager(xDoc.NameTable)
> ns.AddNamespace("cap", "http://www.incident.com/cap/1.0")
>
> --
> Patrick Steele
> http://weblogs.asp.net/psteele