Modify large XML files [modified]
-
Hi everyone :-D , I have a really big question about editing large XML files. Im building a little XML Database engine (like a mini database engine using xml as a storage). I can create tables and select data from them. My question is: since the XmlDocument class loads the entire xml data into memory and data files could take longer than 100 MB, Which is the best way to modify data on large XML files? For example: If i have the next XML file:
<invoices>
<invoice id="1">
<amount>100,000.00</amount>
<currency>Dolar</currency>
<refnum1>9486692001</refnum1>
<refnum2>NULL</refnum2>
<createdate>2008-05-19 4:21:34.532 PM</createdate>
</invoice>
...
</invoices>And that file has like 500.000 rows on it, how can i modify the value of the single node 'RefNum2' where the invoice id is '1' without using the XmlDocument class? I know i can use the XPathNavigator using the xpath string 'Invoices/Invoice[@id="1"]' but how can i set the value and save the file? This is driving me nuts :( ! haha
modified on Monday, May 19, 2008 6:59 PM
-
Hi everyone :-D , I have a really big question about editing large XML files. Im building a little XML Database engine (like a mini database engine using xml as a storage). I can create tables and select data from them. My question is: since the XmlDocument class loads the entire xml data into memory and data files could take longer than 100 MB, Which is the best way to modify data on large XML files? For example: If i have the next XML file:
<invoices>
<invoice id="1">
<amount>100,000.00</amount>
<currency>Dolar</currency>
<refnum1>9486692001</refnum1>
<refnum2>NULL</refnum2>
<createdate>2008-05-19 4:21:34.532 PM</createdate>
</invoice>
...
</invoices>And that file has like 500.000 rows on it, how can i modify the value of the single node 'RefNum2' where the invoice id is '1' without using the XmlDocument class? I know i can use the XPathNavigator using the xpath string 'Invoices/Invoice[@id="1"]' but how can i set the value and save the file? This is driving me nuts :( ! haha
modified on Monday, May 19, 2008 6:59 PM
The core issue is probably that you'd be better off using a database. Is there a SAX implimentation in .NET ? I'd think that's whaty ou need.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )