Page 1 of 1

Adding a new attribute to an element: search and replace

Posted: Tue Sep 27, 2011 5:01 pm
by mike004
I'm trying to work how to achieve the following using Oxygens "find and replace in files" feature.

Find these elements:

//thead/row/entry

Add an attribute role="col" to each entry element that you find.

//thead/row/entry[@role="col"]

I'm not sure which XML find options to enable.

I used Restrict to XPath: //thead/row/entry

after that I was stumped.

Re: Adding a new attribute to an element: search and replace

Posted: Wed Sep 28, 2011 8:51 pm
by adrian
Hello,

Oxygen's find/replace features are string/regular expression driven, with some XML filtering.

Restrict to XPath: //thead/row/entry is a good start, this will limit the search domain to entry elements. Note that this only restricts the domain, you still have to search for an actual string(or regular expression).

Text to find: <entry
Replace with: <entry role="col"
Whole word only enabled to avoid partial matches

Press Replace All to perform the replacement.

Regards,
Adrian

Re: Adding a new attribute to an element: search and replace

Posted: Thu Sep 29, 2011 5:26 pm
by mike004
Thanks, Adrian. that works perfectly.

It's so obvious now...