Re: [xml] libxml Newbie



Robert--

On Monday, June 9, 2003, at 11:20  AM, Robert A. Nurse wrote:

I'm trying to read a small XML file and add an element off the document root then add three child elements to this. Here's what I'm currently doing to add the new info:

if ((newVersionNode = xmlNewDocText(doc, (xmlChar *) "Version")))
  {
xmlNewTextChild(newVersionNode, NULL, (xmlChar *) "number", (xmlChar *) newVersion); xmlNewTextChild(newVersionNode, NULL, (xmlChar *) "startTime", (xmlChar *)
newStartTime);
xmlNewTextChild(newVersionNode, NULL, (xmlChar *) "endTime", (xmlChar *)
newEndTime);
    xmlSaveFormatFile (xmlDocumentName, doc, 1);
  }

I'm a fairly newbie too, but wouldn't you do something like

newVersionNode = xmlNewNode(NULL, (xmlChar *) "Version"));
xmlAddChild(doc, newVersionNode);

and then do the stuff above?

Cheers!
--Chris Ryland / Em Software, Inc. / www.emsoftware.com




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