Find all/ Replace all particular attributes only

Questions about XML that are not covered by the other forums should go here.
farizz145
Posts: 1
Joined: Thu Jul 25, 2019 10:51 pm

Find all/ Replace all particular attributes only

Post by farizz145 »

Hi Guys,

So, I have a bunch of XML files, where the label size is a bit small, so, I want to change only the height, which is the fourth element of the layout attribute, while the other factors remain the same, so, the text is not cut-off. How can I do that at once, using for eg, Find all in Oxygen. Here is an example of a line present in all scripts. I am able to find them all at once, using find all, but cannot replace them all without modifying all the elements.

<BoundLabel layout="370.0,225.0,50.0,10.0" font="bold 11.0pt Tahoma" foreground="green" halign="left" mouseOver="highlight">

In the above line, I want to change 10 to 25, while other elements retain their values.
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Find all/ Replace all particular attributes only

Post by Radu »

Hi,

Oxygen's Find/Replace dialog has an "Xpath" field which you can set to //BoundLabel/@layout in order to limit the search.
Then enable the "Regular Expression" checkbox and search for:

Code: Select all

(\d*\.\d),(\d*\.\d),(\d*\.\d),(\d*\.\d)
replace with:

Code: Select all

\1,\2,60.0,\4
Basically I'm matching all four numbers and replacing keeping the first, second and fourth unmodified but with a custom value for the third one.

Another way to do this if you are comfortable with writing XSLT or XQuery would be to write a custom XSLT stylesheet and use it in an XML refactoring operation.

https://www.oxygenxml.com/doc/versions/ ... tools.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply