Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


need a help to create XML node with text and sub child.

From: erbrmn@-----.---
To: NULL
Date: 3/5/2008 1:57:00 AM
Hi folks

I need a help to create XML node with text and sub child.

--------------------------------------------------------

I want to create "ADDR" node with text and child node.
(First child node and then text.)

  <?xml version="1.0" encoding="UTF-8" ?>
- <ROOT>
- <NODE>
  <child-1 attr="attr-value">This is child text</child-1>
- <ADDR>
  <postcode>12345</postcode>
  Address information
  </ADDR>
  </NODE>
  </ROOT>

--------------------------------------------------------

I can create "ADDR" node with text and child node. But first text and
then child node.
I can not change the location of text and child node of "ADDR" node.

  <?xml version="1.0" encoding="UTF-8" ?>
- <ROOT>
- <NODE>
  <child-1 attr="attr-value">This is child text</child-1>
- <ADDR>
  Address information
  <postcode>12345</postcode>
  </ADDR>
  </NODE>
  </ROOT>

------------------------------------------------------------------------------------
This is code which I did (ASP)
------------------------------------------------------------------------------------

Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")

If (xmlDoc.childNodes.length = 0) Then

	Set objProcInstr = xmlDoc.createProcessingInstruction("xml",
"version=""1.0"" encoding=""UTF-8""")
	xmlDoc.appendChild objProcInstr

	Set root = xmlDoc.createNode("element", "ROOT", "")
	xmlDoc.appendChild(root)

	Set node = xmlDoc.createNode("element", "NODE", "")
	xmlDoc.documentElement.appendChild(node)

	Set child = xmlDoc.createNode("element", "child-1", "")
	Set objAttr = xmlDoc.createAttribute("attr")
	child.setAttribute "attr","attr-value"
	child.text = "This is child text"
	node.appendChild(child)

	Set child = xmlDoc.createNode("element", "ADDR", "")
	node.appendChild(child)
	Set sub_child = xmlDoc.createNode("element", "postcode", "")
	sub_child.Text = "12345"
	child.Text = "Address information"
	child.appendChild(sub_child)

End If

xmlDoc.save (Server.Mappath("newxml.xml"))

-----------------------


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent