Looking for a grep-like tool for XML on Windows

Status
Not open for further replies.

jhmcmullen

Super Member
Registered
Joined
Apr 7, 2009
Messages
59
Reaction score
5
Warning: Jargon ahead!

We've recently switched to DITA, an XML specification. We use Windows XP SP3 boxes, but I spent my formative years with UNIX, so I'm more comfortable in a command line environment, and our PCMS doesn't yet have a search-and-replace tool.

Ungreat. Although we do topic-based writing, relatively little of my work is re-used so I can check it all out. As marketing changes its collective mind frequently, I sometimes have to change most topics in the document--and, depending on the project, it can be several hundred topics.

I would normally use the various UNIX-on-Windows tools, either MKS Toolkit or GNU tools compiled for Windows, except that our PCMS checks out files with multiple hash marks (#) in the directory name and the file name. Escaping them for UNIX is a real pain, and the free shells available are also less than optimal for scripting.

Does anyone know of a Windows tool that will work for search and, by extension, search-and-replace? (We might make one for our use, but the people responsible for that are so overloaded that it won't happen until after the PCMS supports search-and-replace, and that's going to be in a year or three.)

Understand that I don't have a choice about the PCMS or the XML editor we use. That's dictated by the department.
  • A GUI tool I can point at a parent directory is fine if it does search-and-replace.
  • A CLI tool that just does search and spits to standard output is also okay--I can wrap things around it.
  • Free or low-cost would be best, because I'm going to have to pay for the first installment myself.
So....any ideas? This is an area where I'm woefully ignorant.
 

Tsu Dho Nimh

Super Member
Registered
Joined
Sep 2, 2006
Messages
1,534
Reaction score
248
Location
West Enchilada, NM
Search and replace in XML files?

Look at the website file management tools for Windows. They can grep and grope your files and rename files and strings inside them.

Some cheap and free ones are pretty good.

It's been a while, so I can't give you any names, but they do exist.
 

Prawn

Writing is finite,revising infinite
Super Member
Registered
Joined
Aug 28, 2006
Messages
2,361
Reaction score
429
Location
Beast Coast
I don't grok grep, but I decided to post anyway.
 

Ruv Draba

Banned
Joined
Dec 29, 2007
Messages
5,114
Reaction score
1,322
I haven't tried this, but my first thought was to install a mature, grep-friendly editor like emacs for Windows -- or perhaps xemacs. I figured that some emacs variant would be highly XML friendly -- and sure enough here's an IBM article making that claim.

Assuming that the install works well, your main investment would be to learn the editor -- but emacs has always been a pretty spiffy editor -- especially for technical document formats. As it's powerful, mature and gnu-licensed (therefore free) you might get the department on-board for it.

Failing that, try gnu-awk. You could write awk programs to search and replace text. Awk includes grep functions but is more powerful. It can be fiddly to program though, depending on how much XML syntax you want it to know. Next up from awk would be perl - still free, arguably more powerful but a bigger investment to learn to use.

Hope this helps.
 
Last edited:

dclary

Unabashed Mercenary
Poetry Book Collaborator
Requiescat In Pace
Registered
Joined
Oct 17, 2005
Messages
13,050
Reaction score
3,525
Age
57
Website
www.trumpstump2016.com
I have a t-sql grep for finding words or phrases in user objects in sql2000 or better. Nothing for windows in general, though.
 

jhmcmullen

Super Member
Registered
Joined
Apr 7, 2009
Messages
59
Reaction score
5
My biggest problem is coding the actual filenames -- which have to be heavily escaped if I use born-on-Unix tools such as AWK or PERL, which gets to a level of shell coding I barely remember -- and spitting them out. But with a Windows tool, the hash is rarely a special character.

Thanks for the suggestions! I'll try them out.
 
Status
Not open for further replies.