editing attribute values with libxml2?

Hello everyone! I am sorry to bug you, but this site is my last hope. I have tried googling, so, reddit, irc, and various other forums. Anyways, I am writing a todo list app in c. It generates an xml tree that looks something like this: http://paste.ubuntu.com/8272058/ . The problem where I am struggling, is in the function todo_complete, I try to make the attribute of an item switch from false to true. it does it without error, but I can't make it stay that way. here is the code: https://github.com/DTSCode/todo/blob/master/todo.c
Edit: Disregard. I see that you are passing in the element name.

Edit2: It changes the first item to completed="true" for me.
$ ./a.out list
item 1
item n
$ ./a.out complete item
$ ./a.out list
*item 1
item n


Did you step through it with a debugger?

line 167:
if(xmlStrcmp(cur->name, (const xmlChar*) item) == 0) {
You need quotes around item.
Last edited on
it did? did you edit any of the code? also the issue is going to a specific item
Little_Bobby_Tables wrote:
did you edit any of the code?
Nope. Also, commenting out the break statement changes both items to true.

Little_Bobby_Tables wrote:
also the issue is going to a specific item
I think the easiest thing to do would be to use a counter and print it out when you call "todo_list".
Then in "todo_complete", add an item number parameter, iterate over the items until an interal counter is equal to the passed in parameter, and change the "completed" to true.
e.g.
$ ./a.out list
1 item 1
2 item n
$./a.out complete item 2
$./a.out list
1 item 1
* 2 item n

Or maybe add an "item number" property to each item.
Topic archived. No new replies allowed.