W
wappel
I have the following problem:
I have an XML text which consists of several chapters that have a
number-Attribute
<xmltext>
<chapter number="345">
...searchtext...
</chapter>
<chapter number="446">
...searchtext...
</chapter>
</xmltext>
Now I want to replace the ...searchtext... by <search
number="xxx">...searchtext...</search>, where xxx is the value of
number-Attribute of the chapter in which the ...searchtext... stands:
<chapter number="345>
<search number="345">...searchtext</search>
<chapter>
<chapter number="446">
<search number="345">...searchtext</search>
</chapter>
...searchtext... could be a regular expression.
Maybe it is possible to do it with
s/(...searchtext...)/<search number="$variable">$1</search>/gs;
???
But how do I get the right value into the variable?
Thanks for your help
Wolfgang
I have an XML text which consists of several chapters that have a
number-Attribute
<xmltext>
<chapter number="345">
...searchtext...
</chapter>
<chapter number="446">
...searchtext...
</chapter>
</xmltext>
Now I want to replace the ...searchtext... by <search
number="xxx">...searchtext...</search>, where xxx is the value of
number-Attribute of the chapter in which the ...searchtext... stands:
<chapter number="345>
<search number="345">...searchtext</search>
<chapter>
<chapter number="446">
<search number="345">...searchtext</search>
</chapter>
...searchtext... could be a regular expression.
Maybe it is possible to do it with
s/(...searchtext...)/<search number="$variable">$1</search>/gs;
???
But how do I get the right value into the variable?
Thanks for your help
Wolfgang