0

i have pretty much this XML to work with Actionscript 3.0:

<view id="view_lab" class="project.views.Lab" title="-<b><font color'#FF0000'>Lab</font></b>">
<view id="view_lab" class="project.views.Lab" title="-<b><font color'#FF0000'>Lab</font></b>">
<view id="view_lab" class="project.views.Lab" title="-<b><font color'#FF0000'>Lab</font></b>">

And i have this regex to get everything in title TAG: title= /"[^"]"/

Problem is that i want to capture only the "<" and ">" to replace for &gt and &lt without using 2 regex's. Since that XML is already a string.

So i've been trying something like this, which not seems to work unfortunaly: /title="(<)*(>)*([^"])+"/

Ditmar Wendt
  • 668
  • 4
  • 15

1 Answers1

0

Because you're using Actionscript 3, you should not be using a regex to parse XML. Here's some pseudocode that would extract the value of the title attribute:

var myXMLTree:XML = new XML( data );

for (var i:int = 0; i<myXMLTree.view.length(); i++){
    trace(myXMLTree.view[i].@title);
}

Parsing attributes in XML/HTML using regular expressions is a common pitfall, but it should be avoided at all costs.

Please read: RegEx match open tags except XHTML self-contained tags

Community
  • 1
  • 1
Ditmar Wendt
  • 668
  • 4
  • 15