将Xml文件转换为数据库 [英] Converting Xml file to Database
本文介绍了将Xml文件转换为数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个xmlfile,其中包含数据库和数据的架构,我如何使用.NET将该数据保存到同一DBMS或不同DBMS(数据库转换/迁移)中不同数据库的另一个数据库中解决方案
试试下面的链接,希望对您有帮助.
1. http://stackoverflow. com/questions/61233/the-best-way-to-shred-xml-data-into-sql-server-database-columns [ http://social.msdn.microsoft.com/论坛/en/sqlxml/thread/fbab5df9-b884-42bc-9954-07a30b6f911b [
或查看此链接,-
http://msdn.microsoft.com/en-us/library/Aa325640 [ ^ ]
http://www.beansoftware.com/ASP.NET-Tutorials/Using-XML.aspx [ ^ ]
希望对您有所帮助.
使用 System.Xml; XmlDocument doc = 新 XmlDocument(); doc.Load( @" ); // 更新doc.SelectNodes("/RssItem/Rss")和node.Attributes ["Url"].InnnerText到匹配您的xmlfile结构 foreach (XmlNode节点 in doc.SelectNodes(" /RssItem/Rss")) { // 更新对rss(Url)值的插入以匹配您的数据库 字符串 txtSQLQuery = " + node.Attributes [ Url"].InnerText + " ; ExecuteQuery(txtSQLQuery); } }
I have a xmlfile which contain schema of database and data how i can save this data to another database in same DBMS or Different Database in the Different DBMS ( Database conversion/Migration) Using .NET
解决方案
Hi,
Try the links below, I hope this might be helpful to you.
1.http://stackoverflow.com/questions/61233/the-best-way-to-shred-xml-data-into-sql-server-database-columns[^]
2.http://social.msdn.microsoft.com/Forums/en/sqlxml/thread/fbab5df9-b884-42bc-9954-07a30b6f911b[^]
you can try,-
ds.ReadXml("C:\myxmlfile.xml")
or have a look in this links,-
http://msdn.microsoft.com/en-us/library/Aa325640[^]
http://www.beansoftware.com/ASP.NET-Tutorials/Using-XML.aspx[^]
Hope this can help you.
using System.Xml; XmlDocument doc = new XmlDocument(); doc.Load(@"C:\Path\To_my\xmlfile.xml"); //update doc.SelectNodes("/RssItem/Rss") and node.Attributes["Url"].InnnerText to match your xmlfile structure foreach (XmlNode node in doc.SelectNodes("/RssItem/Rss")) { // update the insert into rss (Url) values to match your database string txtSQLQuery = "insert into rss (Url) values ('" +node.Attributes["Url"].InnerText + "')"; ExecuteQuery(txtSQLQuery); } }
这篇关于将Xml文件转换为数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文