Results 1 to 6 of 6

Thread: XPath and XML

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    44

    XPath and XML

    I have an ASP.NET(vb) web application that currently uses xmlWriter(System.Xml) to create an XML document from a database query and write it to a file.

    Now, I need to change this web application to use XPATH to grab data from other XML documents as well as database queries to create an XML document.

    After reading a bit about XPATH, I am wondering if this is even possible.

    I found this bit of info on .NET and XPath on another site:

    XPathDocument: A high performance, read-only cache for processing XML documents and streams. XPathDocument uses the document object model (DOM)-based parsing model (loads the source XML into an in-memory tree structure) but does not implement the interfaces required to insert, to modify, or to delete nodes in an Extensible Markup Language (XML) document or stream.


    Is XPathDocument what I need? From the description, it says it's read only. But I need to be able to use XPath to create an XML document.

    Is there anything I am missing?

    Thanks!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: XPath and XML

    XPath is something used to query an existing structure of XML, it has nothing to do with creation according to the W3C standards. It's simply a way of saying to an implementor, "I want this node's attribute under that node under that node under the fifth node under that node"

    Therefore, it doesn't make sense to use XPath to create a document. For that you have XmlWriter and XmlTextWriter and XmlDocument, all of which let you create XML nodes or files.

    So I suppose the question for you is why do you need to change something that probably works to something else?

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: XPath and XML

    To add to that, the XPathNavigator can be used to modify or add values to a node as well.

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    44

    Re: XPath and XML

    Well, what I meant, was I am still hoping to use XmlWriter, but for some of the nodes, I will need to query other XML documents to populate those nodes. So the new XML document will have data from SQL Server 2005 and other XML docs.

    I guess I was asking, since I will be using XPath, can I still use XmlWriter?

    Thanks

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: XPath and XML

    Unfortunately, no, the writer was only meant to write. If you want to deal with an existing document, then you'll need to use a class that allows you to add nodes and query other nodes with XPath. So for that you can use XPathNavigator and XMLDocument.

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    44

    Re: XPath and XML

    Ok, I understand

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width