本文介绍了将Xml文件转换为数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个xmlfile,其中包含数据库和数据的架构,我如何使用.NET将该数据保存到同一DBMS或不同DBMS(数据库转换/迁移)中不同数据库的另一个数据库中解决方案
试试下面的链接,希望对您有帮助. 1. stackoverflow. com/questions/61233/the-best-way-to-shred-xml-data-into-sql-server-database-columns [ ^ ] 2. social.msdn.microsoft/论坛/en/sqlxml/thread/fbab5df9-b884-42bc-9954-07a30b6f911b [ ^ ]
您可以尝试,- ds.ReadXml("C:\myxmlfile.xml")
或查看此链接,- msdn.microsoft/en-us/library/Aa325640 [ ^ ] www.beansoftware/ASP.NET-Tutorials/Using-XML.aspx [ ^ ] 希望对您有所帮助.
使用 System.Xml; XmlDocument doc = 新 XmlDocument(); doc.Load( @" C:\ Path \ To_my \ xmlfile.xml" ); // 更新doc.SelectNodes("/RssItem/Rss")和node.Attributes ["Url"].InnnerText到匹配您的xmlfile结构 foreach (XmlNode节点 in doc.SelectNodes(" /RssItem/Rss")) { // 更新对rss(Url)值的插入以匹配您的数据库 字符串 txtSQLQuery = " 插入rss(Url)值( '" + 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.stackoverflow/questions/61233/the-best-way-to-shred-xml-data-into-sql-server-database-columns[^] 2.social.msdn.microsoft/Forums/en/sqlxml/thread/fbab5df9-b884-42bc-9954-07a30b6f911b[^]you can try,- ds.ReadXml("C:\myxmlfile.xml")or have a look in this links,- msdn.microsoft/en-us/library/Aa325640[^] www.beansoftware/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文件转换为数据库
发布评论