Re: [xml] Problem with basic libxml functions



Sagar Rastogi said:
Hi
Hi Sagar

       I am working on an enhancement to make the panel-run-dialog
"smart", i.e. it should be able to remember whether the user wanted
to run
a command in terminal or not. So next time the user runs the same
command,
his preference is remembered. (Bug no. 77300).
      I am storing the data in an xml file in the foll. format

<?xml version="1.0"?>
<terminal_preference>
        <command>
                <name> Program name like "galeon" or "nautilus"
</name>
                <terminal> true or false </terminal>
        </command>
        <command>
                ...
        </command>
</terminal_preference>

I am using libxml functions to parse/write to the xml file. I have
used
them exactly in the way specified in examples. Foll is a code
extract:

<snip>

      //cur points to root node at the start.
      cur = cur->xmlChildrenNode;
        printf("Reaches here 3.2 \n");  //This gets printed
        //cur points to command
        while(cur) {
                printf("Reaches here 3.3 \n"); //This gets printed
                child_of_cur = cur->xmlChildrenNode;

<snip>

Ah, a most unfortunate spot to "snip"... I can see what you have
done with the variable "child_of_cur", but I have absolutely no way
to tell what you do in the following lines with it or with the
variable "cur".  Certainly the cause of your "crash" is not on these
specific lines of code, but probably somewhere later in the loop.

The contents of my xml file are:

<?xml version="1.0"?>
<terminal_preference>
</terminal_preference>

      As is obvious from the code extract, the control enters the while
loop
when it shouldn't. The program crashes at the line:

Hmmm... well, it's not obvious to *me* why it shouldn't enter the
while loop.  Your element <terminal_preference> looks to me like it
has text content which will be a child node, so I would expect it to
enter the loop.

 child_of_cur = cur->xmlChildrenNode
      Could somebody please tell me what is the error here?

Regards
Sagar Rastogi

I heartily recommend to you that you learn to use the gdb debugger,
and step through your code.  That should help you to see where you
are going wrong.

Bill




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]