I have an XML document that was a .NET DataSet originally, with schema
information at the top.
Could someone show how, using MSXML v2 "createobject", to copy an
element (that has n attributes) to a new element? Also, how to create
a new element so I can put new attribute data inside?
Thanks.
WenYuan Wang [MSFT] - 26 Jul 2007 09:18 GMT
Hello Lucius
We need to perform more research on this issue . We will reply here as soon
as possible.
If you have any more concerns on it, please feel free to post here.
Thanks for your understanding!
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
WenYuan Wang [MSFT] - 26 Jul 2007 12:56 GMT
Hello Lucius,
Thanks for your wait.
I think you need a JavaScript example in Web Application. Please correct me
if I misunderstand anything here. Thanks.
1) Using MSXML object to Copy an element, you may refer the following code.
var doc = new ActiveXObject("Msxml2.DOMDocument");
doc.loadXML("<?xml version=\"1.0\"
encoding=\"utf-8\"?><root><a>aaaaa</a></root>");
var root = doc.documentElement;
var m = doc.selectSingleNode("/root/a").cloneNode(true);
root.appendChild(m);
alert(doc.xml);
2) Using MSXML object to create a new element: you may refer the following
code.
var doc = new ActiveXObject("Msxml2.DOMDocument");
doc.loadXML("<?xml version=\"1.0\"
encoding=\"utf-8\"?><root><a>aaaaa</a></root>");
var o = doc.createElement("newElement");
var r = doc.createAttribute("id");
r.value="test";
o.setAttributeNode(r);
root.appendChild(o);
alert(doc.xml);
Hope this helps. Please try the above method and let me know if this is
what you need. We will follow up.
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
WenYuan Wang [MSFT] - 30 Jul 2007 12:13 GMT
Hello Lucius,
This is Wen Yuan. I just want to check if there is anything we can help
with.
Have you resolved the issue so far?
Please feel free to update here if you have any concern. We are glad to
assist you.
Have a great day,
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.