DEV Community

Discussion on: Need help with editing a massive file

Collapse
 
dmfay profile image
Dian Fay

Don't use an editor. Write a script that loads the XML file and walks through the tree looking for and eliminating nodes meeting the criteria before writing the file back out. Python's a good choice especially if you're already familiar with it, or you could use Node or any other lightweight scripting language. It'll still take less time than doing it by hand.

Collapse
 
whoisryosuke profile image
Ryosuke

@hoahchris

Basically this.

I had to do this a lot with XML exports from Wordpress. Here's a script I wrote on Github that sorts through XML using PHP to get you started. It converts XML to TXT files, but you can see how I parse and loop through the XML nodes.

Collapse
 
rhymes profile image
rhymes

Why don't use you an XPath based to extract the nodes?