Jump to content
  • Advertisement
Sign in to follow this  
mrmrcoleman

Processing a file full of XML

This topic is 3644 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I have a file full of XML with seemingly random carriage returns and spaces, just one big mess basically. What I need to do is find every instance of <a>foo and then skip forwards in the file and output the matching <d>bar</d> for that record ignoring any carriage returns or whitespace encountered on the way. I believe my saving grace here is that each XML record has the same fields for every record so, do you guys have any ideas on how I can achieve this on the command line in Linux? I could hack together a small tool but I'd really rather avoid that! Thanks in advance for any help on this, Mark

Share this post


Link to post
Share on other sites
Advertisement
TinyXPath, or similar XPath library. A non-library-based solution is pretty much guaranteed to be fragile and hackish, grumbled about later by programmers who know how XML works. Don't be that guy.

Share this post


Link to post
Share on other sites
Thanks for the feedback guys. I managed it in the end by Googling a combination of SED and AWK and learning just enough.

It's not pretty, but I didn't have to do any coding, and I've learned something!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!