我試圖劃分一個XML文件到部分 我有這樣C#分水嶺XML成零件
<?xml version="1.0" encoding="utf-8"?>
<RegistrationOpenData xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.gov">
<Description>Registration data is collected by ABC XYZ</Description>
<InformationURL>http://www.example.com/html/hpd/property-reg-unit.shtml</InformationURL>
<SourceAgency>ABC Department of Housing</SourceAgency>
<SourceSystem>PREMISYS</SourceSystem>
<StartDate>2016-02-29T00:03:06.642772-05:00</StartDate>
<EndDate i:nil="true" />
<Registrations>
<Registration xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<RegistrationID>1</RegistrationID>
<BuildingID>1A</BuildingID>
<element1>E11</element1>
<element2>E21</element2>
<element3>E31</element3>
<element4>E41</element4>
</Registration>
<Registration xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<RegistrationID>2</RegistrationID>
<BuildingID>2A</BuildingID>
<element1>E21</element1>
<element2>E22</element2>
<element3>E32</element3>
<element4>E42</element4>
</Registration>
</Registrations>
</RegistrationOpenData>
一個XML文件,我試圖獲取節點的數量低谷這段代碼
XmlDocument doc = null;
doc = new XmlDocument();
doc.Load(@"D:\Registrations20160229.xml");
XmlNodeReader nodeReader = new XmlNodeReader(doc);
XmlElement root = doc.DocumentElement;
XmlNodeList elemList = root.GetElementsByTagName("Registration");
int totalnode = elemList.Count;
int nodehalf = totalnode/2;
MessageBox.Show(nodehalf.ToString());
但是在這之後我無法繼續,這段代碼我已經用來計算註冊節點的數目然後把它們變成了一半,現在我不知道如何進一步去分割這個文件,我總共有158718條目(註冊節點)內的文件(有時甚至更多),我是試圖打破所有部分,也許3至4部分。
你能告訴我們實際的症狀是什麼,你看到的?不需要將文件分成3至4個部分。當你說「因規模而失敗」時,你可以詳細瞭解一下這方面的情況嗎?你收到了什麼錯誤信息? –
我試圖將它加載到一個數組中,然後運行「for循環」以獲得30,000個條目的一部分,但它無法一次加載完整文件並顯示內存不足異常 – Hanumendra
請顯示無法使用的代碼。您向我們展示了一段代碼,然後告訴我們一個_different_代碼塊不起作用。 –