use RE to fix XML attributes

use RE to fix XML attributes

4
NewbieNewbie
4

    Nov 24, 2005#1

    Hi folks,

    I have an XML document, but it is not very well formatted: a large number of the node attributes are not enclosed in quotes. e.g.

    Code: Select all

    <Node attr1=hello attr2=goodbye>node text here</Node>
    Is there a neat RE that I can run that will find all attributes that don't have a quote round their value and insert them?

    Thanks for your assistance!!

    344
    MasterMaster
    344

      Nov 24, 2005#2

      Hi Mum,

      try this:
      find string:

      Code: Select all

      \=([a-z]+)([\s>]*)
      replace string:

      Code: Select all

      \='\1'\2
      then it looks like this:

      Code: Select all

      <Node attr1='hello' attr2='goodbye'>node text here</Node>
      NOTE: UNIX REGEXP IS ON !!! See "options, search"


      rds Bego
      Normally using all newest english version incl. each hotfix. Win 10 64 bit

      4
      NewbieNewbie
      4

        Nov 24, 2005#3

        Hey Bego,

        Thanks a million for this. It wasn't quite perfect for my situation, but gave me a huge head-start.

        For the record, I used this:
        find string:

        Code: Select all

        \=([a-z0-9]+)([\s>]*)
        replace string:

        Code: Select all

        \="\1"\2

        344
        MasterMaster
        344

          Nov 25, 2005#4

          Hy mim,

          thats what this forum is good for :D

          Next time, also say what exactly the output should look like.

          greetz from germany
          Normally using all newest english version incl. each hotfix. Win 10 64 bit