Here's the problem: I need to use regexp to add an attribute xml files with a value from a different attribute in the same xml tag.

Example: For every element where there is a name attribute , if there is no id attribute in the element, I need to have it created with the same value of the name attribute. If there is an id attribute already, then it is retained.


<acct acct="aex113" country_code="us" name="abcde" />
<acct acct="aex114" name="eeaad" country_code="us" ><status>open</status>
<acct acct="aex115" country_code="us" name="eoo" id="eoo9" />

<acct acct_id="aex113" country_code="us" name="abcde" id="abcde" />
<acct acct_id="aex114" name="eeaad" id="eeaad" country_code="us" ><status>open</status>
<acct acct_id="aex115" country_code="us" name="eoo" id="eoo9" />

Thanks in advance!

Re: Regular Expressions Regexp question: add additional attribute to xml elements with same value of another attribute


How are you doing this processing Are you reading in each element node and processing the regex, or is this just an Xml file to be sent to one regex