[xml] New programming question.
- From: Nathanael Noblet <nathanael gnat ca>
- To: xml gnome org
- Subject: [xml] New programming question.
- Date: Fri, 15 Oct 2004 09:08:08 -0700
Hello,
I hope I have the right list for this question. I'm learning the
libxml library for a project I'm attempting. I've enjoyed the many
examples, unfortunately, I can't seem to get what I want to happen.
Here's what I have. Please keep in mind that I am using this as a
learning experience, and not for the basis of a real program, but to
learn libxml programming.
static char *methodResponse = "<?xml
version=\"1.0\"?><methodResponse><params></params></methodResponse>";
then in a test function I parse the above from memory like so
doc =
xmlReadMemory(methodResponse,strlen(methodResponse),"noname.xml",NULL,0)
;
I loop through the nodes till xmlStrcmp(cur_node->name,"params")
returns true. Then I start to construct some more nodes like this
tmp_node = xmlNewNode(NULL,"param");
xmlNewChild(tmp_node,NULL,"int","1");
xmlAddChild(cur_node,tmp_node);
then I write out to a file like so:
xmlSaveFormatFile("path/to/file",doc,0);
What I expect to see is this
<?xml
version=\"1.0\"?><methodResponse><params><param><int>1</int></param></
params></methodResponse>
instead I get
<?xml
version=\"1.0\"?><methodResponse><params/><param><int>1</int></param></
methodResponse>
Is this because when I parse it initially there is nothing in the
params node so it condenses it down to <params/>? How do I get it to
add to that node? What do I not understand? Reading material or links
to help me figure this out would be great.
--
Nathanael D. Noblet
Gnat Solutions
412 - 135 Gorge Road E
Victoria, BC V9A 1L1
T/F 250.385.4613
http://www.gnat.ca/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]