Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Howto: Adding new nodes to XML file [Thread Next] Re: Howto: Adding new nodes to XML fileTo: NULL Date: 6/2/2004 11:26:00 AM "Arjen Steur" <arjensteur@h...> wrote in message
news:40bd8549$0$1735$abc4f4c3@n......
> 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
> ----------------------------------------------------------------------
When you save the file you need to save back to where you initially opened
it from. The account will need to have write permission to the folder. The
account will be the IIS account if using anonymous login or the user of the
page if using NTFS permissions.
--
Joe (MVP - xml)
>
> '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/LegendLa
bel")
> 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 | |||
|
