Re: XPath from String



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?
>>
>>
>>


.



Relevant Pages

  • Using XPath to copy nodes
    ... private Element getAnswers(Element root, String queID) throws ... XPath xpath = factory.newXPath; ... //Design the query to search through the XML Document ...
    (comp.lang.java.programmer)
  • Using XPath to copy nodes
    ... private Element getAnswers(Element root, String queID) throws ... XPath xpath = factory.newXPath; ... //Design the query to search through the XML Document ...
    (comp.lang.java.programmer)
  • Re: Using XPath Against A Node
    ... top parent? ... Or is the entire xml document sent with it. ... In terms of the XPath implementation with SelectSingleNode and SelectNodes if the node is not inserted in the owning document then it looks like the XPath / evaluates to the node itself. ...
    (microsoft.public.dotnet.languages.vb)
  • implementation of xpath in ruby?
    ... I have used token types to parse xml ... returns the tag end of an xml document. ... now i need to implement xpath in my parser class. ...
    (comp.lang.ruby)
  • Re: SelectSingleNode in C#
    ... you need an Xml Document which contains your XML string: ... XmlDocument oXmlDoc = new XmlDocument; ... Then you can get a specific, single node, by specifying a valid XPath ...
    (microsoft.public.dotnet.framework.windowsforms)