.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
insystem.xml.linq
namespacethe code can as
ds.readxml(xdocument.parse(xml).root.elements().first().createreader());
Comments
Post a Comment