VB.NET | XML Namespace parsing issues
-
Hello, This is my first delve into XML namespaces and I'm having a VERY difficult time parsing the XML because of the Namespace. If I remove the namespace then I get no problems. It would really be appreciated if anybody out there can cure my headache! Here is my code: Dim xmlDoc As New System.Xml.XmlDocument() Dim resolver as XmlUrlResolver = new XmlUrlResolver() Dim datasource as XmlDataSource = new XmlDataSource() resolver.Credentials = New NetworkCredential("username", "password") xmlDoc.XmlResolver = resolver xmlDoc.Load("http://somedomain.com/webservicename") Dim xsn as XmlNamespaceManager = new XmlNamespaceManager(xmlDoc.NameTable) xsn.AddNamespace("t", "urn:ahw:itemlist") xmlData.Document = xmlDoc xmlData.TransformSource = "test.xsl" Here is the XML: Here is the xsl:
Display Name
Name
Here is my asp.net page (the main part where I want the XML to display):
Thanks so much for your time! Chris
-
Hello, This is my first delve into XML namespaces and I'm having a VERY difficult time parsing the XML because of the Namespace. If I remove the namespace then I get no problems. It would really be appreciated if anybody out there can cure my headache! Here is my code: Dim xmlDoc As New System.Xml.XmlDocument() Dim resolver as XmlUrlResolver = new XmlUrlResolver() Dim datasource as XmlDataSource = new XmlDataSource() resolver.Credentials = New NetworkCredential("username", "password") xmlDoc.XmlResolver = resolver xmlDoc.Load("http://somedomain.com/webservicename") Dim xsn as XmlNamespaceManager = new XmlNamespaceManager(xmlDoc.NameTable) xsn.AddNamespace("t", "urn:ahw:itemlist") xmlData.Document = xmlDoc xmlData.TransformSource = "test.xsl" Here is the XML: Here is the xsl:
Display Name
Name
Here is my asp.net page (the main part where I want the XML to display):
Thanks so much for your time! Chris
Well, first I gotta ask if there's a typo in your input XML. The end tag for the document element doesn't match. The next thing I'd like to know is what is the error you're getting? Do you get the error when you load the document, when you put it in the data document, or when you run the transform?
-
Well, first I gotta ask if there's a typo in your input XML. The end tag for the document element doesn't match. The next thing I'd like to know is what is the error you're getting? Do you get the error when you load the document, when you put it in the data document, or when you run the transform?
-
Hello, This is my first delve into XML namespaces and I'm having a VERY difficult time parsing the XML because of the Namespace. If I remove the namespace then I get no problems. It would really be appreciated if anybody out there can cure my headache! Here is my code: Dim xmlDoc As New System.Xml.XmlDocument() Dim resolver as XmlUrlResolver = new XmlUrlResolver() Dim datasource as XmlDataSource = new XmlDataSource() resolver.Credentials = New NetworkCredential("username", "password") xmlDoc.XmlResolver = resolver xmlDoc.Load("http://somedomain.com/webservicename") Dim xsn as XmlNamespaceManager = new XmlNamespaceManager(xmlDoc.NameTable) xsn.AddNamespace("t", "urn:ahw:itemlist") xmlData.Document = xmlDoc xmlData.TransformSource = "test.xsl" Here is the XML: Here is the xsl:
Display Name
Name
Here is my asp.net page (the main part where I want the XML to display):
Thanks so much for your time! Chris
Try putting two slashes before itemlist:
<xsl:template match="//itemlist">
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Try putting two slashes before itemlist:
<xsl:template match="//itemlist">
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Hello, This is my first delve into XML namespaces and I'm having a VERY difficult time parsing the XML because of the Namespace. If I remove the namespace then I get no problems. It would really be appreciated if anybody out there can cure my headache! Here is my code: Dim xmlDoc As New System.Xml.XmlDocument() Dim resolver as XmlUrlResolver = new XmlUrlResolver() Dim datasource as XmlDataSource = new XmlDataSource() resolver.Credentials = New NetworkCredential("username", "password") xmlDoc.XmlResolver = resolver xmlDoc.Load("http://somedomain.com/webservicename") Dim xsn as XmlNamespaceManager = new XmlNamespaceManager(xmlDoc.NameTable) xsn.AddNamespace("t", "urn:ahw:itemlist") xmlData.Document = xmlDoc xmlData.TransformSource = "test.xsl" Here is the XML: Here is the xsl:
Display Name
Name
Here is my asp.net page (the main part where I want the XML to display):
Thanks so much for your time! Chris
-
Ah the namespace. Of course. Should have seen that :sigh:
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook