Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Can I load an XPath result XmlNodeList into a Dataset/DataGrid?

Can I load an XPath result XmlNodeList into a Dataset/DataGrid?

Scheduled Pinned Locked Moved XML / XSL
csharpxmldatabasehelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jack80918
    wrote on last edited by
    #1

    I'm writing a C# Windows/.Net 2.0 app which will take a large XML document as an initial input. My form has 4 basic controls: 3 comboboxes (Country, State, and City) for filtering the XML data and a DataGrid to display the results. The XML doc has this format: I have no problem using XPath queries to extract the values to populate the Country, State, and City comboboxes; each selection drives the data in the subsequent combobox. Upon selection in the City combobox, I can query for a resulting set of 'locations'. My problem is how to stuff this XmlNodeList into a DataSet which I can then use with my DataGrid. I have no problem reading an entire document into a DataSet DataSet ds = new DataSet(); ds.ReadXml("Test.Search.xml"); but have no idea how to stuff an XmlNodeList into one. Thanks. Jack80918

    G 1 Reply Last reply
    0
    • J jack80918

      I'm writing a C# Windows/.Net 2.0 app which will take a large XML document as an initial input. My form has 4 basic controls: 3 comboboxes (Country, State, and City) for filtering the XML data and a DataGrid to display the results. The XML doc has this format: I have no problem using XPath queries to extract the values to populate the Country, State, and City comboboxes; each selection drives the data in the subsequent combobox. Upon selection in the City combobox, I can query for a resulting set of 'locations'. My problem is how to stuff this XmlNodeList into a DataSet which I can then use with my DataGrid. I have no problem reading an entire document into a DataSet DataSet ds = new DataSet(); ds.ReadXml("Test.Search.xml"); but have no idea how to stuff an XmlNodeList into one. Thanks. Jack80918

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      As you probably already know, an XmlNodeList is really a collection XmlNodes. You have mentioned you can read an XML document directly into a DataSet. So, I can give you a some suggestions. 1. You can create an XmlDocument populating it with XmlNodes cloned from the XmlNodeList. 2. You can create an XmlDocument using XSLT with the same criteria you used to create the XmlNodeList. 3. You can create a DataTable (or DataTables) that corresponds to your XmlNodeList and extract data from your XmlNodes into the appropriate rows and columns. There are certainly other ways of doing this. So, search the web for ideas or just be creative.

      "We make a living by what we get, we make a life by what we give." --Winston Churchill

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups