Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Howto: Adding new nodes to XML file Howto: Adding new nodes to XML fileTo: 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")
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
