From 0e6700cf55637ab514ada5bd14bfa5d407b8625e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=96=D1=83=D0=BC?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=BD?= Date: Tue, 22 May 2018 13:07:03 +0300 Subject: [PATCH] sync myhtml lexborisov/myhtml/issues/139 --- source/myhtml/serialization.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source/myhtml/serialization.c b/source/myhtml/serialization.c index c142c91..ffc5c45 100755 --- a/source/myhtml/serialization.c +++ b/source/myhtml/serialization.c @@ -58,6 +58,17 @@ mystatus_t myhtml_serialization_tree_callback(myhtml_tree_node_t* scope_node, my { myhtml_tree_node_t* node = scope_node; + /* + Document node it is a root node of tree, it is not a tag element. + + For HTML, the root element will always be tag. + It is always present in the HTML document and it always a root of HTML document. + */ + + if(scope_node && scope_node->tree && scope_node->tree->document == scope_node) { + node = scope_node->child; + } + while(node) { if(myhtml_serialization_node_callback(node, callback, ptr)) return MyCORE_STATUS_ERROR_MEMORY_ALLOCATION; @@ -550,4 +561,3 @@ mystatus_t myhtml_serialization_node_buffer(myhtml_tree_node_t* node, mycore_str return myhtml_serialization_node_callback(node, myhtml_serialization_concatenate, str); } -