PDA

View Full Version : xml / asp problem


flyclassic
09-24-2002, 06:15 AM
'Creating a NodeList of the elements in the XML Tree
Set objNodeList = objDom.documentElement.childNodes


'Loop through each item in the NodeList and check if its NodeType is that of a Processing Instruction i.e.

for i = 0 to objNodeList.length

Set objNode=objNodeList.item(i)
If objNode.nodeType = 7 then

set objNewPI = objDom.createProcessingInstruction("YourApp"," ")
objNewPI.data = objNode.data

objNode.parentNode.replaceChild objNewPI, objNode

End If

next


These is the script to modify the xml processing instructions. Its actually written in javascript but i've converted it to ASP and it can't work.

In the asp file, whenever it runs till

Set objNode=objNodeList.item(i) line, it has error occured. and thus i can't save my file.
anybody can help....?



original xml /javascript is
<SCRIPT >

/*Declaring memvars to be used later */
var objDOM;
var objNode;
var objNodeList;
var objNodeListEle;
var i;
var objNewPI;

/* Instantiating the XML Parser */
objDOM = new ActiveXObject("MSXML.DOMDocument");

/*Opening the file nodename.xml inysc mode */
objDOM.async = false;
objDOM.load("ModProcInstr.xml")

alert("ModProcInstr.xml loaded in memory")

/*Creatubg a NodeList of the elements in the XML Tree */
objNodeList = objDOM.documentElement.childNodes;

/*Establishing and Displaying the number of elements in the XML tree in memory */
objNodeListEle = objNodeList.length

alert("The number of elements in the NodeList array is:" + objNodeListEle);

/*Loop through each item in the NodeList and check if its NodeType is that of a Processing Instruction i.e. 7*/
for(i=0;i<objNodeList.length;i++)
{
objNode=objNodeList.item(i);

if(objNode.nodeType ==7)
{
objNewPI = objDOM.createProcessingInstruction("YourApp"," ");
objNewPI.data = objNode.data
objNode.parentNode.replaceChild(objNewPI, objNode);
alert("New Processing Instruction created");
}
}

glenngv
09-24-2002, 07:24 AM
cross-posted
http://www.codingforums.com/showthread.php?threadid=6623

you should not start a new thread of the same topic so that other users can follow the previous discussion. That way, more people may be able to help you.

in the link that i provided you in the previous thread, there is a snippet to create processing instruction:

'Create the xml processing instruction.
Set objPI = objDom.createProcessingInstruction("xml", "version='1.0'")

'Append the processing instruction to the XML document.
objDom.insertBefore objPI, objDom.childNodes(0)

Alex Vincent
09-25-2002, 01:56 AM
Closing the other thread.

flyclassic
09-25-2002, 02:04 AM
okay, sorry .