diff --git a/gxml/GXmlDocument.vala b/gxml/GXmlDocument.vala index 5a82d5f60b3b1483bb5af695900478861cc7048b..8758118fa7748ba6f12a625248000c176de76239 100644 --- a/gxml/GXmlDocument.vala +++ b/gxml/GXmlDocument.vala @@ -85,9 +85,9 @@ public class GXml.GDocument : GXml.GNode, GXml.Document return false; } // GXml.Node - public override Gee.Map attrs { owned get { return new GHashMapAttr (this, _node); } } - public override Gee.BidirList children { owned get { return new GListChildren (this, _node); } } - public override Gee.List namespaces { owned get { return new GListNamespaces (this, _node); } } + public override Gee.Map attrs { owned get { return new GHashMapAttr (this, doc->get_root_element ()); } } + public override Gee.BidirList children { owned get { return new GListChildren (this, doc->get_root_element ()); } } + public override Gee.List namespaces { owned get { return new GListNamespaces (this, doc->get_root_element ()); } } public override GXml.Document document { get { return this; } } // GXml.Document public bool indent { get; set; default = false; } diff --git a/gxml/libxml-Document.vala b/gxml/libxml-Document.vala index 73ca11d2512692a6aa43282428753ff6151e7c6b..c84da1c4b83ac116c35e3b544937a498e2261551 100644 --- a/gxml/libxml-Document.vala +++ b/gxml/libxml-Document.vala @@ -287,6 +287,7 @@ namespace GXml { this.doctype = new xDocumentType (doc->int_subset, doc->ext_subset, this); } this.implementation = new Implementation (); + _node_list = new NodeChildNodeList (this.xmldoc->get_root_element (), this.owner_document); } /** @@ -513,7 +514,7 @@ namespace GXml { doc = new Xml.Doc (); this.from_libxml2 (doc, false); - _node_list = new NodeChildNodeList ((Xml.Node*)this.xmldoc, this.owner_document); + _node_list = new NodeChildNodeList (this.xmldoc->get_root_element (), this.owner_document); } /** diff --git a/test/gxml-performance.vala b/test/gxml-performance.vala index 5394e779541cf4de889ceff0d918c8da01c703a6..f17250ba5c8e8ea0901a3eff947754ec21d3838d 100644 --- a/test/gxml-performance.vala +++ b/test/gxml-performance.vala @@ -119,10 +119,19 @@ class BookStore : SerializableContainer public class Performance { - public static void iterate (Document doc) { - foreach (GXml.Node node in doc.root.children) { - string n = node.name; - string v = node.value; + /** + * Iterate recursively through all node and children nodes in document. + */ + public static void iterate (GXml.Node node) { + foreach (GXml.Node n in node.children) { + int i = node.children.size; + string name = n.name; + string val = n.value; +#if DEBUG + GLib.message ("Node: "+name+" Val: "+val+ " Children: "+i.to_string ()); +#endif + if (i > 0) + Performance.iterate (n); } } public static void add_tests ()