I have a insanely large file that has a lot of customer data in XML format. The start of a customer <CUSTOMER> and end </CUSTOMER> are how I'll determine the starting and ending points of the customer data I need to extract. The <DOC_NUM> is the number I'll be searching for. I'll input a regular text file with 12-byte document numbers into the file (Doc Number List.txt), search the massive XML file (example.xml) for those document numbers, find the data before and after the DOC_NUM tags, but within the CUSTOMER tags and extract it to a formated file. The formated file needs to have these tags, <?xml version="1.0" encoding="ISO-8859-1"?>

Any help is greatly appreciated.


Import the source XML into a DataTable.
Then you can use the Select() method to filter out what you're looking for.
The result can then be exported into a new destination XML.