XML DOM QUERY - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

XML DOM QUERY

Hi

I am facing some problem in XML. Please help me out if possible.

This is my XML file:


<?xml version="1.0"?>


Pop
Come On Over
Shania Twain


Country and Western
Red Dirt Girl
Emmylou Harris




And the following code is written in an HTML page:





set objXMLDoc=CreateObject("Microsoft.XMLDOM")
objXMLDoc.async="false"
objXMLDoc.load("albums.xml")
set NewText = objXMLDoc.createTextNode("Country")
document.write(objXMLDoc.documentElement.lastChild.firstChild.nodeName)
set Category = objXMLDoc.documentElement.lastChild.firstChild
set OldText = Category.firstChild
Category.replaceChild NewText, OldText
objXMLDoc.save("albums.xml")




In the above code, I am trying to replace an old node with a new one. When I run the HTML file in the browser I get an error message saying "Permission denied". I am not able to understand why is this so.

Please help me out.

Thanx
suvendu


Comments

  • lionblionb Posts: 1,688Member ✭✭
    I'm not sure that will help by you can try it at least.
    According to Microsoft XML SDK 4.0 Help:
    Calling load or loadXML on an existing document immediately discards the content of the document.
    If loading an XML document from a resource, the load must be erformed asynchronously or the load will fail. For example:
    (Take a look at line with .async method)

    Set objXML = CreateObject("MSXML2.DOMDocument")

    ObjXML.async=true

    objXML.load "res://msxml.dll/DEFAULTSS.XSL"
    WScript.echo objXML.parseError.reason
    objXML.save "c:defaultss.xsl"




    : Hi
    :
    : I am facing some problem in XML. Please help me out if possible.
    :
    : This is my XML file:
    :
    :
    : <?xml version="1.0"?>
    :
    :
    : Pop
    : Come On Over
    : Shania Twain
    :
    :
    : Country and Western
    : Red Dirt Girl
    : Emmylou Harris
    :
    :
    :
    :
    : And the following code is written in an HTML page:
    :
    :
    :
    :
    :
    : set objXMLDoc=CreateObject("Microsoft.XMLDOM")
    : objXMLDoc.async="false"
    : objXMLDoc.load("albums.xml")
    : set NewText = objXMLDoc.createTextNode("Country")
    : document.write(objXMLDoc.documentElement.lastChild.firstChild.nodeName)
    : set Category = objXMLDoc.documentElement.lastChild.firstChild
    : set OldText = Category.firstChild
    : Category.replaceChild NewText, OldText
    : objXMLDoc.save("albums.xml")
    :
    :
    :
    :
    : In the above code, I am trying to replace an old node with a new one. When I run the HTML file in the browser I get an error message saying "Permission denied". I am not able to understand why is this so.
    :
    : Please help me out.
    :
    : Thanx
    : suvendu
    :
    :
    :

Sign In or Register to comment.