[xml] Behavior of the parser

Date view Thread view Subject view Author view

From: Marc Billaud (marcbill@wanadoo.fr)
Date: Mon Sep 04 2000 - 15:30:36 EDT


Hello everybody

I want to ask you information about a behavior, I ve noticed on the
parser after having used it on the example of libxml "gjobs.xml". I ve
modified the code of the example "gjobread.c" in order to see how it
works and also to add "gtk function". At the moment I have removed all
the "gtk functions" because I don't master well the "libxml". So to
begin to parse I just use:

 21 doc = xmlParseFile(filename);
22 if(doc == NULL){
23 printf("ParseFile NULL");
24 return NULL;
25 }

37 cur = xmlDocGetRootElement(doc);
38 ns = xmlSearchNsByHref(doc, cur,
"http://www.gnome.org/some-location");
39
I put a breakpoint with the gdb debugger on line 38 and I ve noticed
something strange when I verify values of "doc and cur variables". Here
the results:

(gdb) print *cur
$8 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x8059d40
"Helping",
  children = 0x8059c40, last = 0x805b628, parent = 0x8059bc0, next =
0x0, prev = 0x0,
  doc = 0x8059bc0, ns = 0x8059d70, content = 0x0, properties = 0x0,
nsDef = 0x8059d70}
(gdb) print *cur->children
$9 = {_private = 0x0, type = XML_TEXT_NODE, name = 0x8059c78 "text",
children = 0x0,
  last = 0x0, parent = 0x8059d08, next = 0x8059cc8, prev = 0x0, doc =
0x8059bc0, ns = 0x0,
  content = 0x8059c88 "\n ", properties = 0x0, nsDef = 0x0}
(gdb) print *cur->children-next
No symbol "next" in current context.
(gdb) print *cur->children->next
$10 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x8059d50 "Jobs",
  children = 0x8059dc0, last = 0x805b5e0, parent = 0x8059d08, next =
0x805b628,
  prev = 0x8059c40, doc = 0x8059bc0, ns = 0x8059d70, content = 0x0,
properties = 0x0,
  nsDef = 0x0}
(gdb) print *cur->children->next->children
$11 = {_private = 0x0, type = XML_TEXT_NODE, name = 0x8059d60 "text",
children = 0x0,
  last = 0x0, parent = 0x8059cc8, next = 0x8059e18, prev = 0x0, doc =
0x8059bc0, ns = 0x0,
  content = 0x8059ca8 "\n\n ", properties = 0x0, nsDef = 0x0}
(gdb) print *cur->children->next->children->next
$12 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x8059e50 "Job",
  children = 0x8059e60, last = 0x805b5a8, parent = 0x8059cc8, next =
0x805b5e0,
  prev = 0x8059dc0, doc = 0x8059bc0, ns = 0x8059d70, content = 0x0,
properties = 0x0,
  nsDef = 0x0}
(gdb) print *cur->children->next->children->next->children
$13 = {_private = 0x0, type = XML_TEXT_NODE, name = 0x8059df8 "text",
children = 0x0,
  last = 0x0, parent = 0x8059e18, next = 0x8059f78, prev = 0x0, doc =
0x8059bc0, ns = 0x0,
  content = 0x8059e08 "\n ", properties = 0x0, nsDef = 0x0}

Between a parent node and child node I got a node called "text". This
node called "text" can make pbs when you have to parse an imput XML file
in which you don't know the name of the different nodes (eg: an XML
editor).

Is this a normal behavior? or do I forget something in my code to
prevent this node text to appear?

Thanks for your ideas about this pb.
Bye
Marc

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Sep 04 2000 - 16:44:00 EDT