fix bug in XhtmlNode

This commit is contained in:
Grahame Grieve 2023-03-16 15:42:04 +11:00
parent 413cbb115a
commit cf9bd54a74
1 changed files with 3 additions and 5 deletions

View File

@ -508,13 +508,11 @@ public class XhtmlNode extends XhtmlFluent implements IBaseXhtml {
try {
XhtmlDocument fragment = new XhtmlParser().parse(val, "div");
XhtmlNode root = fragment.getChildNodes().get(0);
// Skip the <? .. ?> declaration if one was present
XhtmlNodeList nodes = fragment.getChildNodes();
XhtmlNode root = nodes.get((nodes.size() > 0 && nodes.get(0) != null && nodes.get(0).getNodeType() == NodeType.Instruction) ? 1 : 0);
this.attributes = root.attributes;
this.childNodes = root.childNodes;
// Strip the <? .. ?> declaration if one was present
if (childNodes.size() > 0 && childNodes.get(0) != null && childNodes.get(0).getNodeType() == NodeType.Instruction) {
childNodes.remove(0);
}
this.content = root.getContent();
this.name = root.getName();
this.nodeType= root.getNodeType();