in reply to Re: (jeffa) Re: Regex for XML attributes...
in thread Regex for XML attributes...

Yes, the unquoted 2 and 3 level attributes need to be quoted, else XML::Simple complains:
not well-formed (invalid token) at line . . .
Also, i really don't think this will do what you think:
<heading> level="3", blah blah blah </heading>
You really should change that to:
<heading level="3">blah blah blah</heading>
You are welcome for the solution! . . . i would like to see a regex that solved the problem as well, but i imagine it would be an unruly beast . . . anybody? beuller? japhy?

Hmmmm, on second thought - this is something probably best not done!

Replies are listed 'Best First'.
Re: (jeffa) 3Re: Regex for XML attributes...
by tshabet (Beadle) on Aug 24, 2001 at 02:24 UTC
    Heh heh, I should explain myself further..... I was using "XML" loosely since, as you point out, this is not a valid XML syntax. My example code is actually the output from a script I wrote for another application, which is the transfer of a language specification written in another language into XML. The original language has the ability to give several attributes to its tags, such that the ultimate original for my examples would have been something on the order of
    {heading bob=foo, super=duper, level=3, blah blah blah}
    which my original script converts to the
    <heading> bob=foo, super=duper, level=3, blah blah blah </heading>
    format. Now I'm tacking on some code to handle these attributes (which don't occur in the syntax I originally wrote the script for) so that I have
    <heading bob=foo super=duper level=3>blah blah blah </heading>
    So I was thinking that I would save myself some trouble by using a regex. Anyway, the example code is the product of my script thus far and was not supposed to be well formed quite yet, which I should have said in the first place. :-) </CODE>