Re: [xml] what functions



Get the node and change the field ... it is a structure.

xmlNodePtr cur;
xmlNodePtr start = xmlDocGetRootElement(docname);
//error checking
tag = "tiger";

for (cur=start->children;cur;cur=cur->next) {
           if (!xmlStrcmp(cur->name,tag)) {
                        xmlNodeSetContent(cur,"ddd");
}

This is HIGHLY oversimplified in that I am not traversing sub levels, etc .... and the code may work fine for you if you have already gotten the node pointer for the tag above what you are interested in (e.g. "start" would not be the top of the document, it would be the node pointer for <animal> in this case). Or if you already have <tiger> then just set the content. There are functions to set just about everything including attributes.

Note you may want to use: xmlEncodeEntitiesReentrant(document,value); to encode your values properly.


At 12:38 AM 3/24/04, you wrote:
Hello,
I have got sth like:

        <animal>
                <tiger>ffff</tiger>
        </animal>

I would like to change content of <tiger> from "fff" to "ddd". I know that
there is possibility to unlink node tiger and after thar re-create it with
other content but I would like to make it without deleting it.
Is there a function making it in that way..?

I am working on RH 8.0, gcc 3.2, libxml2-2.4.23-1




_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml

Eric S. Eberhard
(928) 567-3727          Voice
(928) 567-6122          Fax
(800) 569-1122 Denver Office (I am never there, you can leave a message)
(720) 339-4765          Cell

http://www.vicspdi.com

Completely updated web site of personal pictures with many new pictures! Includes horses, dogs, Corvairs, and more.

http://www.vicspdi.com/ourpics/index.html




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