On 21 Sep 2011, at 9:42 AM, Brian wrote:
> I have an XML document which uses self-closing tags containing id
> attributes of varying length for a variety of different elements. I
> need to convert these to opening and closing tags which contain the
> attribute value. For example I need to change:
>
> <BaseVehicle id="5888"/>
> <Position id="22"/>
>
> Into:
>
> <BaseVehicle>5888</BaseVehicle>
> <Position>22</Position>
>
> I'm perfectly happy to change just one tag type at a time, for example
> all <BaseVehicle> tags and then run it again to change all <Position>
> and other tag types in the document. Any help anyone can offer would
> be tremendously appreciated. Thanks!
This one's easy. Set Grep in the Find panel, and
Search:
<(\w+) id="([^"]+)"/>
(lessthan, remember a run of "word" characters, space-id=-quote, remember any
characters up to quote, quote-slash-greaterthan)
Replace:
<\1>\2</\1>
(tag containing the remembered word, remembered quoted characters, closing tag
containing the remembered word)
You might want to click Find All first, to verify that the pattern will affect
what you hope it will.
— F
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>