markup = AJAX_COMPONENT_CDATA_CLOSE.matcher(markup).replaceAll("</component>");
XmlPullParser parser = new XmlPullParser();
parser.parse(markup);
XmlTag elm;
XmlTag openTag = null;
XmlTag closeTag = null;
int level = 0;
while ((elm = parser.nextTag()) != null && closeTag == null)
{
XmlTag xmlTag = elm;
if (openTag == null)
{
IValueMap attributeMap = xmlTag.getAttributes();
for (Map.Entry<String, Object> entry : attributeMap.entrySet())
{
String attr = entry.getKey();
if (attr.equals(attribute) && value.equals(entry.getValue()))
{
if (xmlTag.isOpen())
{
openTag = xmlTag;
}
else if (xmlTag.isOpenClose())
{
openTag = xmlTag;
closeTag = xmlTag;
}
}
}
}
else
{
if (xmlTag.isOpen() && xmlTag.getName().equals(openTag.getName()))
{
level++;
}
if (xmlTag.isClose())
{
if (xmlTag.getName().equals(openTag.getName()))
{
if (level == 0)
{
closeTag = xmlTag;
closeTag.setOpenTag(openTag);