Transformation of BIG XML files

Topics: Developer Forum, User Forum, XPathmania
Mar 10, 2010 at 7:00 PM
Edited Mar 10, 2010 at 7:07 PM

Hello,

I have xml files that should be transfomated. I tried to use simple XSL Transformation and it works pretty well for small files.

With bigger files (more than 100 MB) I get OutOfMemory exception during transformation.

I investigated this problem and found that I should combine  XmlTextReader with XPath to achive best performance.

Could Mvp.Xml help me with this?

I have such structure of input XML:

<Products>
	<Product>
		<Id>2</Id> 
		<Name>SomeName</Name>
		<CategoryID>2</CategoryID>
	</Products>
	...
	<Product>
		<Id>5</Id> 
		<Name>SomeName</Name>
		<CategoryID>1</CategoryID>
	</Product>
</Products>

<Categories>
	<Category>
		<Id>1</Id>
		<CategoryName>CategoryName</CategoryName>
	</Category>
	...
	<Category>
		<Id>1</Id>
		<CategoryName>CategoryName</CategoryName>
	</Category>
</Categories>

And I should get such output XML:

<Categories>
	 <Category Id="1" Name="CategoryName">
		<Products>
			 <Products Id="5" Name="SomeName" CategoryID="1" .../>
			...

		</Products>

	</Category>
	 <Category Id="2" Name="CategoryName">
		<Products>

			  <Products Id="2" Name="SomeName" CategoryID="2" .../>
			 ...
		 </Products>
	</Category>
</Categories>

XML should become nested.

Could you help me?

 

Thanks.