generate xml at runtime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zombie

    #1

    generate xml at runtime

    hello,
    I am generating an XML document at run time.
    I have been able to create the root element and the elements below it
    but I am not able to add attributes to elements. Can anyone please
    send a snippet on how to do this?

    Thanks.

    The sample code I am using is:

    ----------------------------------------------------
    HRESULT hr;
    IXMLDOMDocument 2Ptr pXMLDoc;
    IXMLDOMNodePtr pNode;
    IXMLDOMProcessi ngInstructionPt r pi;

    hr = pXMLDoc.CreateI nstance("Msxml2 .DOMDocument.4. 0");
    pi = pXMLDoc->createProcessi ngInstruction(" xml", "version=\"1.0\ "");
    pXMLDoc->appendChild(pi );

    pNode = pXMLDoc->createNode("1" , "root", "");
    pXMLDoc->appendChild(pN ode);

    pNode = pXMLDoc->createNode("1" , "element1", "");
    pXMLDoc->documentElemen t->appendChild(pN ode);

    ------------------------------------------------------
  • Andy Dingley

    #2
    Re: generate xml at runtime

    On 18 Oct 2004 03:24:53 -0700, natkhatbandar@y ahoo.com (Zombie) wrote:
    [color=blue]
    >I have been able to create the root element and the elements below it
    >but I am not able to add attributes to elements.[/color]

    Try the .setAttribute() method

    Comment

    Working...