|
|
|
start date: Wed, 25 Jul 2007 07:57:35 -0400,
posted on: microsoft.public.dotnet.languages.jscript
back
| Thread Index |
|
1
lucius am
|
|
2
(WenYuan Wang [MSFT])
|
|
3
(WenYuan Wang [MSFT])
|
|
4
(WenYuan Wang [MSFT])
|
Copy Element and Create New?
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.
Date:Wed, 25 Jul 2007 07:57:35 -0400
Author:
|
RE: Copy Element and Create New?
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.
Date:Thu, 26 Jul 2007 08:18:16 GMT
Author:
|
RE: Copy Element and Create New?
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.
Date:Thu, 26 Jul 2007 11:56:44 GMT
Author:
|
RE: Copy Element and Create New?
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.
Date:Mon, 30 Jul 2007 11:13:42 GMT
Author:
|
|
|