Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > generate xml at runtime

Reply
Thread Tools

generate xml at runtime

 
 
Zombie
Guest
Posts: n/a
 
      10-18-2004
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;
IXMLDOMDocument2Ptr pXMLDoc;
IXMLDOMNodePtr pNode;
IXMLDOMProcessingInstructionPtr pi;

hr = pXMLDoc.CreateInstance("Msxml2.DOMDocument.4.0");
pi = pXMLDoc->createProcessingInstruction("xml", "version=\"1.0\"");
pXMLDoc->appendChild(pi);

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

pNode = pXMLDoc->createNode("1", "element1", "");
pXMLDoc->documentElement->appendChild(pNode);

------------------------------------------------------
 
Reply With Quote
 
 
 
 
Andy Dingley
Guest
Posts: n/a
 
      10-18-2004
On 18 Oct 2004 03:24:53 -0700, (Zombie) wrote:

>I have been able to create the root element and the elements below it
>but I am not able to add attributes to elements.


Try the .setAttribute() method
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to generate Java Code from XML at runtime? Lucia Java 7 08-19-2011 09:38 AM
Failed to generate a user instance of SQL Server. Only an integratedconnection can generate a user instance. Harlan Messinger ASP .Net 2 03-28-2010 06:51 PM
How to generate warnings when How generate a warning when int is converted to bool or vice versa? PengYu.UT@gmail.com C++ 3 04-06-2006 11:24 PM
How to generate variable labels for same component within a generate loop Weng Tianxiang VHDL 5 02-16-2006 01:45 PM
ASP XML Support - Generate XML string from FORM DATA based on XML schema Matt ASP General 3 04-23-2004 07:12 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57