summaryrefslogtreecommitdiff
path: root/src/xmlfixups.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmlfixups.cpp')
-rw-r--r--src/xmlfixups.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/xmlfixups.cpp b/src/xmlfixups.cpp
index 2c05e3a..3989a0c 100644
--- a/src/xmlfixups.cpp
+++ b/src/xmlfixups.cpp
@@ -620,26 +620,22 @@ void XmlFixups::runPassTwo(const DOM::Document& doc)
DOM::Element parent = (const DOM::Element&)el.getParentNode();
if(parent != NULL)
{
- // Loop till we find no more of the same
- for(;;)
- {
- DOM::Node next = el.getNextSibling();
-
- if(next == NULL || next.getNodeType() != DOM::Node::ELEMENT_NODE)
- break;
-
- // If it's the same type of element ...
- if(!DOMHelpers::isEqualElement((DOM::Element&)next, el))
- break;
-
- // NOTE: Notice we do nothing with attributes. Currently
- // all elements in the duplicates list don't need that.
-
- while(next.hasChildNodes())
- el.appendChild(next.removeChild(next.getFirstChild()));
-
- // Remove duplicate node
- parent.removeChild(next);
+ DOM::Node prev = el.getPreviousSibling();
+
+ if(prev != NULL && prev.getNodeType() == DOM::Node::ELEMENT_NODE)
+ {
+ // If it's the same type of element ...
+ if(DOMHelpers::isEqualElement((DOM::Element&)prev, el))
+ {
+ // NOTE: Notice we do nothing with attributes. Currently
+ // all elements in the duplicates list don't need that.
+
+ while(prev.hasChildNodes())
+ el.appendChild(prev.removeChild(prev.getFirstChild()));
+
+ // Remove duplicate node
+ parent.removeChild(prev);
+ }
}
}
}