DOM...hjælp !!!
Jeg har en streng, der indeholder XMLdenne streng vil jeg bearbejde med DOM
Meeeeen...hvordan får jeg DOM til at skrive den nye streng tilbage igen????
Jeg er ved at gå amok !
Her er min kode :
<%
Dim strSoeg, objXML, rootNode, childNodes, strTest, XMLstreng, XMLstart, antalNode, xmlDoc
XMLstart = \"<?xml version=\'1.0\'?>\"
Set Kurv = Session(\"Kurv\")
Dim XMLtemp
dim keyarray
dim i
Keyarray = Kurv.Keys
For i = 0 to Kurv.Count - 1
%>
<% CDnr = (Keyarray(i))%>
<% Antal=Kurv.Item(Keyarray(i))%>
<%
Set Con = Server.CreateObject( \"ADODB.Connection\" )
Con.Open \"DSN=XMLTEST.mdb\"
Set RS = Con.Execute( \"SELECT * FROM CD WHERE CDID=\"& CDnr )
%>
<%Set objXML = server.CreateObject(\"Microsoft.XMLDOM\")%>
<% WHILE NOT RS.EOF%>
<% strTest = RS(\"CDData\")
objXML.LoadXML(strTest)
Set rootNode = objXML.documentElement
If rootNode.hasChildNodes() Then
For each pageNode in rootNode.childNodes
For each propertyNode in pageNode.childNodes
If propertyNode.nodeName = \"Kunstner\" Then
If InStr(propertyNode.Text, strSoeg) Then
XMLstreng = XMLstreng + mid(strTest, 12, ((len(strTest)-23))) \'fjerner cdobject tags\'ne og samler XMLstreng
End if
End if
Next
Next
End if
RS.MoveNext
Wend
next
XMLstreng = XMLstreng + \"</CD_object>\" \'XMLstreng saml %>
<%XMLstreng=XMLstart+XMLstreng
%>
<% Con.Close %>
<% Set Con = Nothing
objXML.load(XMLstreng)
objXML.save(Server.Mappath(\"domnode.xml\"))%>// Her skulle det egenligt gemmes i en streng !
<% set objXML = Nothing%>
<%
\'set xmlDoc=CreateObject(\"Microsoft.XMLDOM\")
\'xmlDoc.async=\"false\"
\'xmlDoc.load(XMLstreng)
\'response.write(XMLstreng)
Set Kurv = Session(\"Kurv\")
dim keyarray2
dim y
Keyarray2 = Kurv.Keys
For y = 0 to Kurv.Count - 1
%>
<% CDnr = (Keyarray2(y))%>
<% Antal2=Kurv.Item(Keyarray2(y))%>
<%
dim antal
set xmlDoc = Server.CreateObject(\"Microsoft.XMLDOM\")
xmlDoc.async=\"false\"
xmlDoc.load(Server.Mappath(\"domnode.xml\"))
for each x in xmlDoc.documentElement.childNodes
Set rootNode = xmlDoc.documentElement
If rootNode.hasChildNodes() Then
set newnode=xmlDoc.createElement(\"Antal\")
For each pageNode in rootNode.childNodes
pageNode.appendchild(newnode)
For each propertyNode in pageNode.childNodes
If propertyNode.nodeName = \"Antal\" Then
propertyNode.text = 4
end if
next
next
end if
\'response.write(x.nodename)
\'response.write(\": \")
\'response.write(x.text)
next
next