Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Howto: Adding new nodes to XML file

From: Arjen Steur <arjensteur@-------.--->
To: NULL
Date: 6/2/2004 9:46:00 AM
Hi,

I'm quite new to XML and i've got the following problem:

I've got a base-XML-DOM object in which I want to add information from 
another XML file as a new node. The adding goes okay, at least in the 
temporary objects, but I cant get the information back into the 
BaseXMLDom. Below I added the code (ASP VBScript, MWX can be read as XML)

I hope you can help me,

Greetings

Arjen Steur
----------------------------------------------------------------------

'Paths
	Dim PathFile	'Path of current file
	Dim RootDir	'Root directory for the application
	Dim RootMWX	'Root directory for MWX Files
	Dim BaseMWX	'Overall XML formatted Map Window File (MWF)
	Dim TempMWX	'MWX part for Layers and Layergroups
	
	
	'XML related
	Dim MWFDoc			'Map Window File (MWF) Object
	Dim BaseMwxDOM		'Base MWX XML file
	Dim TempMwxDOM		'Temp MWX XML file used for layers and layergroups
	Dim BaseMwxRE		'Root Element of the Base MWX
	Dim TempMwxRE		'Root Element of the Temporary MWX
	Dim BaseMwxMLs		'MapLayers Node of the Base MWX
	
	Dim TempNode		'Temporary node element for changing values
	Dim DataType		'Datatype of a particular Layer (same within a layergroup)
	
	'Filesystem related
	Dim FileSO			'File System Object
	Dim Folder			'Folder Object
	Dim SubFol			'Subfolder
	Dim SubFolFile		'File in subfolder
	
	'---------------------------------------'
	'	Initialisation
	'---------------------------------------'
	'Paths
	PathFile			= Request.ServerVariables("PATH_TRANSLATED")
	RootDir				= Left(PathFile,InstrRev(Pathfile,"\www\"))
	RootMWX				= RootDir & "MWX\"
	BaseMWX				= RootMWX & "base.mwx"
	
	'XML related
	set BaseMwxDom		= Server.CreateObject("Microsoft.XMLDOM")
	BaseMwxDom.async = false
	BaseMwxDom.Load(BaseMWX)
	Set BaseMwxRE		= BaseMwxDom.documentElement
	Set BaseMwxMLs		= BaseMwxRE.selectSingleNode("MapLayerGroups")
	
	'Filesystem related
	set FileSO			= Server.CreateObject("Scripting.FileSystemObject")
	set Folder			= FileSO.GetFolder(RootDir & Ucase(Session("user")) & "\SDF\")

	'---------------------------------------'
	'	Implementation
	'---------------------------------------'
	Response.Write(BaseMwxDom.Load(BaseMWX))
	for each SubFol in Folder.SubFolders
		Response.Write("<br><br><b>" & SubFol.Name & "</b><br>")
		'Create Layer Group
		IniFileLoad("..\" & Session("user") & "\SDF\" & SubFol.Name & 
"\LGSettings.ini")
		DataType			= IniFileValue("LayerGroup|DataType")
		
		TempMWX				= RootMWX & "layer_group.mwx"
		set TempMwxDom		= Server.CreateObject("Microsoft.XMLDOM")
		TempMwxDom.async	= false
		TempMwxDom.Load(TempMWX)
		Set TempMwxRE		= TempMwxDom.documentElement
		
		Set TempNode		= 
TempMwxRE.selectSingleNode("//MapLayerGroup/MapLayerGroupProperties/Name")
		TempNode.text		= SubFol.Name
		Set TempNode		= 
TempMwxRE.selectSingleNode("//MapLayerGroup/MapLayerGroupProperties/LegendLabel")
		TempNode.text		= SubFol.Name

		BaseMwxMLs.appendChild(TempMwxRE)
			
		'for each SubFolFile in SubFol.files
		'	If Not IsIni(SubFolFile.Name) Then
		'		'Create SDF Layer
		'	End If
		'next
	next
	'BaseMwxDom.appenchild(BaseMwxMLs)
	set BaseMwxDom.DocumentElement = BaseMwxMLs
	BaseMwxDom.Save("d:\test\lalalala.mwx")


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