[xml] How to change the content
- From: "Shi, Charles" <ccshi qualcomm com>
- To: <xml gnome org>
- Subject: [xml] How to change the content
- Date: Thu, 10 Apr 2003 15:02:05 -0700
Hi
The buffer contains the XML, the size contains the length of the XML.
Then I call the following function.
I want to change the value in "reference" tag from whatever
in it to "a-xxx". After the function call. I would like to see
the buffer has this change.
Could you tell me what is the right way to do this?
Thank you very much
Charles
-------------------------------------------------------------------
const int XMLNode::parseMessageNode(char* buffer, const int size)
{
xmlChar* mem;
xmlNodePtr tag, subtag;
m_doc = xmlParseMemory(buffer, size);
if (m_doc == NULL)
return -1;
m_node = xmlDocGetRootElement(m_doc);
if (m_node == NULL)
return -1;
if (xmlStrcmp(m_node->name, (const xmlChar*) "mobilesys") != 0)
return -1;
tag = m_node->xmlChildrenNode;
while (tag != NULL)
{
if (xmlStrcmp(tag->name, (const xmlChar*) "node") == 0)
{
subtag = tag->xmlChildrenNode;
while (subtag != NULL)
{
if (xmlStrcmp(subtag->name, (const
xmlChar*) "reference") ==
0)
{
mem = xmlGetProp(subtag, (const
xmlChar*)"reftype");
fprintf(stderr, "Prop: %s**\n",
mem);
xmlFree((void *)mem);
mem =
xmlNodeListGetString(m_doc,
subtag->xmlChildrenNode, 1);
fprintf(stderr, "Content: %s\n",
mem);
xmlFree((void *)mem);
xmlNodeSetContentLen(subtag,
(const
xmlChar*)"a-xxx", 5);
}
subtag = subtag->next;
}
}
tag = tag->next;
}
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]