问题描述:

Suppose i have the following xml :

<books>

<book>

<name>book 1</name>

<author>aut 1</author>

<length unit="cm">297</length>

</book>

</books>

When i read this xml into a dataset using :

dataSet.ReadXml(xmlPath)

It will return a dataset with 2 tables: books and length. The table 'books' will contain 2 columns : 'name' and 'author'. The other table 'length' will contain all lengths.

I just want 1 table, 'books' with all 3 columns. The attribute 'unit' should just be ignored ... How do you do that ?

Edit: sorry, I solved it by just removing the text in the xml file :

 mainXML = mainXML.Replace(" unit=\"K\"", "");

网友答案:

Create a typed DataSet in the designer that contains the relevant tables and fields. Then call ReadXml on an instance of that DataSet. This should work and also be more comfortable when accessing data.

网友答案:

I just read the xml file, removed the attributes and saved again. Not pretty, but it works ...

mainXML = mainXML.Replace(" unit=\"K\"", ""); 
相关阅读:
Top