.net - Load something other than the root node of an XML file using ReadXML -


i'm trying load xml file embedded database (sqlite) using .net. best way i've found read data datatable/dataset , use dataadapter update datatable database table.

the problem is, xml file have work has data isn't in root node. there's root node (tables), subnode (tablexxx) , of data in subnode.

when use readxml (for dataset object), reads in single record (containing name of subnode table). want ignore root node , treat first subnode if root node.

how go doing this?

(or, if there's easier way load xml file database, i'd interested in hearing well, although i'm guessing i'll still need work around root node issue).

watyf

string xml = "<tables><table1><col1>xyz</col1></table1></tables>";  dataset ds = new dataset(); ds.readxml(xdocument.parse(xml).root.element("table1").createreader());  var value = ds.tables[0].rows[0]["col1"].tostring(); //<-- xyz 

edit

  • xdocument in system.xml.linq namespace

  • the code can as

    ds.readxml(xdocument.parse(xml).root.elements().first().createreader());


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -