我有以下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