Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I was trying to Generate a XML from DataTable and with the help of the XML i will query it by using XPATH. Everything was working fine but the XPATH was not working because the XML what i generated does not have any Attributes in the XMLNodes up to my knowledge XPATH or XQuery will work only on the XML or IEnumerable<xelement> only when it has attribute with it. so how can i create a Attribute for the XML.

Note:
The reason why i was usign XPATH or XQuery is i was handeling with large amount of data ( 100000+) so i have tried creating attributed using a Foreach. since i was taking more time basically it was not recommened. so any one can Advise me some other plan. some BULK Attribute Creating logic which will not slow down my process.

Please let me know if any one can't understand or any mistakes in my post. Thanks
Posted
Comments
Mohan Gopi 13-Aug-13 5:49am    
Hi _AKA_KSN_, use this datatable.WriteXml(strDirectory, XmlWriteMode.WriteSchema); let me know if aything.
[no name] 14-Aug-13 6:36am    
Hope Schema will add a tag with field type and some namespace kind of thing. it Won't add any attribute to the XmlElements.



FYI:

Summary from the XmlWriteMode.WriteSchema
// Summary:
// Writes the current contents of the System.Data.DataSet as XML data with the
// relational structure as inline XSD schema. If the System.Data.DataSet has
// only a schema with no data, only the inline schema is written. If the System.Data.DataSet
// does not have a current schema, nothing is written.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900