我有以下XML文件:保存XML数据在C#
<os:tax>
<os:cat name="abc" id="1">
<os:subcat name="bcd" id="11">
<os:t name="def" id="111">
<os:cut name="hello" id="161" cutURL="/abc/a.html"/>
<os:cut name="hello2" id="162" cutURL="/abc1/a1.html"/>
<os:cut name="hello3" id="163" cutURL="/abc4/a3.html"/>
</os:t>
</os:subcat>
</os:cat>
<os:cat name="def" id="2">
<os:subcat name="bcd" id="22">
<os:t name="def" id="222">
<os:cut name="hello" id="171" cutURL="/abcs/a.html"/>
<os:cut name="hello2" id="172" cutURL="/abcs1/a1.html"/>
<os:cut name="hello3" id="173" cutURL="/abcs4/a3.html"/>
</os:t>
</os:subcat>
</os:cat>
</os:tax>
它有更多的OS:在它的猫。只是在这里显示两个易于使用。我在oracle中有这样的表格:
ID os_lev title parent_id cut_url
1 cat abc null null
11 subcat bcd 1 null
111
161
162
163
2
22
...
我想填满这张表。我想知道在c#中使用控制台应用程序执行此操作的最佳方法是什么? 我做的是:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("C:\\getxml.xml");
XmlNodeList tax= xmlDoc.GetElementsByTagName("os:tax");
foreach (XmlNode node in tax)
{
//here i will save all the nodes? What is the best way to do this?
//Also should i do a insert in oracle right here?
}
这应该是的foreach内尝试循环?
文档中表中有多少条记录,以及它们必须多久更换一次。有很多方法可以对这个cat进行皮肤处理。例如,XMLDocument会将整个XMLReader加载一个节点。 –
@Tony - 我正在使用LINQ获取所有数据,我想知道如何将该数据移动到Oracle数据库。表应该拥有与文件中许多节点一样多的记录。 – Gurnor