Re: XPath from String
- From: "Scott M." <s-mar@xxxxxxxxxxxxx>
- Date: Mon, 16 Jan 2006 09:56:00 -0500
A System.XML.XMLDocument object has 2 methods for loading it up with XML.
XMLDocument.Load(xmlTextFile)
XMLDocument.LoadXML(xmlString)
Use the second one and then use standard XPath for parsing.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxmldocumentclassloadxmltopic.asp
"Joe Pannone" <JoePannone@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:48D8E528-078B-4F8A-81FE-9AEED3EE6753@xxxxxxxxxxxxxxxx
> Its NOT a text file, its a 'text' value in a SQL Server table.
>
> I have a (SQL Server 2005) table with a field (defined as TEXT) that
> contains
> an XML document. In VB.NET (VS 2005) I need to get this xml document and
> perform XPath statements on it. When I get the XML document and convert
> it
> to a string I loose part of the document.
>
> Dim xmltext As New System.Text.StringBuilder
> Dim strReader As StringReader = New StringReader(xmltext.ToString)
> Dim reader As XmlTextReader = New XmlTextReader(strReader)
> Dim strSQL As New System.Text.StringBuilder
>
> strSQL.Append("SELECT msg as VAL from tblMessage WHERE ID=100")
> 'routine ExecSQLReturnVal executes a SQL statements are returns VAL
> xmltext.Append(ExecSQLReturnVal(strSQL.ToString))
> strReader = New StringReader(xmltext.ToString)
> reader = New XmlTextReader(strReader)
> docNav = New XPathDocument(reader)
>
>
> now 'xmltext' does not have the full XML document, it has been cut off
>
> Scott, Do you have an example in VB.NET to load the text?
>
>
>
> "Scott M." wrote:
>
>> Load the text file into an XMLDocument and use XPath from there?
>>
>>
>> "Joe Pannone" <JoePannone@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:5340B1B7-5737-43A7-870A-E9A850615D91@xxxxxxxxxxxxxxxx
>> > Does anyone have an example on using an XPath statement (in VB.NET)
>> > where
>> > the
>> > source XML document is NOT a file, but a 'text' value from SQL Server?
>>
>>
>>
.
- References:
- Re: XPath from String
- From: Scott M.
- Re: XPath from String
- Prev by Date: Re: XPath from String
- Next by Date: RE: Problems Reading XML File
- Previous by thread: Re: XPath from String
- Next by thread: Re: XPath from String
- Index(es):
Relevant Pages
|