I need a way to allow a variable to equal an xml document. When using
xpathdocument the parameter is asking for a filename. Since I plan on doing
a lot of search in the xml document I would like to supply a variable instead
of the xml doc.
This is the code I use:
dim docNav As XPathDocument
docNav = New XPathDocument("c:\adsp_dispatch.xml")
I would like to use something like:
dim docNav As XPathDocument
dim curXMLDoc = [a SQL statenent that gets the XML message/document from my
SQL server]
docNav = New XPathDocument(curXMLDoc)
I found the following code, but I cannot get it to work:
Dim mySelectQuery As String = "select msg as val from tblMessage
where id=1011 FOR XML AUTO, XMLDATA, " & _
"ELEMENTS, BINARY BASE64"
Dim myConnectString As String =
"server=xxxx;uid=sa;password=xxx;database=xxxx "
Dim sqlConn As SqlConnection = New SqlConnection(myConnectString)
sqlConn.Open()
Dim sqlComm As SqlCommand = New SqlCommand(mySelectQuery, sqlConn)
sqlComm.CommandTimeout = 15
Dim reader As XmlTextReader = CType(sqlComm.ExecuteXmlReader(),
XmlTextReader)
' Instantiate an XPathDocument using the XmlTextReader.
' Dim doc As XPathDocument = New XPathDocument(reader,
XmlSpace.Preserve)
docNav = New XPathDocument(reader, XmlSpace.Preserve)
Please help...