replacechild problem xml

Ερωτήσεις και απαντήσεις σχετικές με την HTML, XHTML και την κατασκευή σελίδων για το Web.

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
Άβαταρ μέλους
mihalisp
Δημοσιεύσεις: 123
Εγγραφή: 04 Ιουν 2002 03:00
Επικοινωνία:

replacechild problem xml

Δημοσίευση από mihalisp » 25 Ιούλ 2002 19:27

i have a form where a user puts some information in the text fields and
this information goes to an xml file.but if the user puts some information
there and after a few minutes wants to go back to this page to change some
information this new information must replace the existing information in
the xml file without creating the existing information again.i use
the "createelement" but with this the xml creates both the existing
information and the new.i used the "replacechild" but this doesn't
work.Can anyone help me?Also,i think that it needs a conditional
instruction:if the node already exists,then make the replacement not add
the new node(new information),else append the new node.How can i manage
this?Plz help!

the code i used is this :

<%
Set Upload = Server.CreateObject("Persits.Upload")
Upload.Save

Function AddContactXML(strXMLFilePath, strFileName)

Dim objDom, sourceFile, objRoot, obj1, obj2, obj3, obj4, obj5, obj6, obj7,
obj8, obj9, obj10, obj11, obj12, obj13, obj14, obj15, obj16, obj17, obj18,
obj19, obj20, obj21, obj22, obj23


sourceFile = strXMLFilePath & "\" & strFileName

Set objDom = server.CreateObject("Microsoft.XMLDOM")
objDom.preserveWhiteSpace = True

objDom.load(sourceFile)

Set objRoot = objDom.documentElement


if Not IsObject(objRoot) Then
Response.Write " No file loaded"
end if

if not node.childNodes.i(6) then

Set obj1 = objDom.createElement("eponimo")
obj1.Text = Upload.Form(1)
objRoot.appendChild obj1

Set obj2 = objDom.createElement("onoma")
obj2.Text = Upload.Form(2)
objRoot.appendChild obj2

Set obj3 = objDom.createElement("onoma_patera")
obj3.Text = Upload.Form(3)
objRoot.appendChild obj3

Set obj4 = objDom.createElement("afm")
obj4.Text = Upload.Form(4)
objRoot.appendChild obj4

Set obj5 = objDom.createElement("dieu_epp")
obj5.Text = Upload.Form(5)
objRoot.appendChild obj5

Set obj6 = objDom.createElement("til_epp")
obj6.Text = Upload.Form(6)
objRoot.appendChild obj6

Set obj7 = objDom.createElement("ar_taut")
obj7.Text = Upload.Form(7)
objRoot.appendChild obj7

Set obj8 = objDom.createElement("dieu")
obj8.Text = Upload.Form(8)
objRoot.appendChild obj8

Set obj9 = objDom.createElement("tilefono")
obj9.Text = Upload.Form(9)
objRoot.appendChild obj9

Set obj10 = objDom.createElement("eggamos")
obj10.Text = Upload.Form(10)
objRoot.appendChild obj10

Set obj11 = objDom.createElement("eponimo_s")
obj11.Text = Upload.Form(11)
objRoot.appendChild obj11

Set obj12 = objDom.createElement("onoma_s")
obj12.Text = Upload.Form(12)
objRoot.appendChild obj12

Set obj13 = objDom.createElement("onoma_pat_s")
obj13.Text = Upload.Form(13)
objRoot.appendChild obj13

Set obj14 = objDom.createElement("afm_s")
obj14.Text = Upload.Form(14)
objRoot.appendChild obj14

Set obj15 = objDom.createElement("dieu_epp_s")
obj15.Text = Upload.Form(15)
objRoot.appendChild obj15

Set obj16 = objDom.createElement("til_epp_s")
obj16.Text = Upload.Form(16)
objRoot.appendChild obj16

Set obj17 = objDom.createElement("ar_taut_s")
obj17.Text = Upload.Form(17)
objRoot.appendChild obj17

Set obj18 = objDom.createElement("ekpr_epon")
obj18.Text = Upload.Form(18)
objRoot.appendChild obj18

Set obj19 = objDom.createElement("ekpr_onoma")
obj19.Text = Upload.Form(19)
objRoot.appendChild obj19

Set obj20 = objDom.createElement("ekpr_onoma_pat")
obj20.Text = Upload.Form(20)
objRoot.appendChild obj20

Set obj21 = objDom.createElement("ekpr_afm")
obj21.Text = Upload.Form(21)
objRoot.appendChild obj21

Set obj22 = objDom.createElement("ekpr_dieu")
obj22.Text = Upload.Form(22)
objRoot.appendChild obj22

Set obj23 = objDom.createElement("ekpr_til")
obj23.Text = Upload.Form(23)
objRoot.appendChild obj23

else

Set obj1 = objDom.createElement("eponimo")
obj1.Text = Upload.Form(1)
objRoot.replaceChild obj1 , obj1

Set obj2 = objDom.createElement("onoma")
obj2.Text = Upload.Form(2)
objRoot.replaceChild obj2 , obj2

Set obj3 = objDom.createElement("onoma_patera")
obj3.Text = Upload.Form(3)
objRoot.replaceChild obj3 , obj3

Set obj4 = objDom.createElement("afm")
obj4.Text = Upload.Form(4)
objRoot.replaceChild obj4 , obj4

Set obj5 = objDom.createElement("dieu_epp")
obj5.Text = Upload.Form(5)
objRoot.replaceChild obj5 , obj5

Set obj6 = objDom.createElement("til_epp")
obj6.Text = Upload.Form(6)
objRoot.replaceChild obj6 , obj6

Set obj7 = objDom.createElement("ar_taut")
obj7.Text = Upload.Form(7)
objRoot.replaceChild obj7 , obj7

Set obj8 = objDom.createElement("dieu")
obj8.Text = Upload.Form(8)
objRoot.replaceChild obj8 , obj8

Set obj9 = objDom.createElement("tilefono")
obj9.Text = Upload.Form(9)
objRoot.replaceChild obj9 , obj9

Set obj10 = objDom.createElement("eggamos")
obj10.Text = Upload.Form(10)
objRoot.replaceChild obj10 , obj10

Set obj11 = objDom.createElement("eponimo_s")
obj11.Text = Upload.Form(11)
objRoot.replaceChild obj11 , obj11

Set obj12 = objDom.createElement("onoma_s")
obj12.Text = Upload.Form(12)
objRoot.replaceChild obj12 , obj12

Set obj13 = objDom.createElement("onoma_pat_s")
obj13.Text = Upload.Form(13)
objRoot.replaceChild obj13 , obj13

Set obj14 = objDom.createElement("afm_s")
obj14.Text = Upload.Form(14)
objRoot.replaceChild obj14 , obj14

Set obj15 = objDom.createElement("dieu_epp_s")
obj15.Text = Upload.Form(15)
objRoot.replaceChild obj15 , obj15

Set obj16 = objDom.createElement("til_epp_s")
obj16.Text = Upload.Form(16)
objRoot.replaceChild obj16 , obj16

Set obj17 = objDom.createElement("ar_taut_s")
obj17.Text = Upload.Form(17)
objRoot.replaceChild obj17 , obj17

Set obj18 = objDom.createElement("ekpr_epon")
obj18.Text = Upload.Form(18)
objRoot.replaceChild obj18 , obj18

Set obj19 = objDom.createElement("ekpr_onoma")
obj19.Text = Upload.Form(19)
objRoot.replaceChild obj19 , obj19

Set obj20 = objDom.createElement("ekpr_onoma_pat")
obj20.Text = Upload.Form(20)
objRoot.replaceChild obj20 , obj20

Set obj21 = objDom.createElement("ekpr_afm")
obj21.Text = Upload.Form(21)
objRoot.replaceChild obj21 , obj21

Set obj22 = objDom.createElement("ekpr_dieu")
obj22.Text = Upload.Form(22)
objRoot.replaceChild obj22 , obj22

Set obj23 = objDom.createElement("ekpr_til")
obj23.Text = Upload.Form(23)
objRoot.replaceChild obj23 , obj23
end if

'objDom.insertBefore objPI, objDom.childNodes(0)

objDom.Save(sourceFile)


Set objDom = nothing
Set objRoot = nothing
Set obj1 = nothing
Set obj2 = nothing
Set obj3 = nothing
Set obj4 = nothing
Set obj5 = nothing
Set obj6 = nothing
Set obj7 = nothing
Set obj8 = nothing
Set obj9 = nothing
Set obj10 = nothing
Set obj11 = nothing
Set obj12 = nothing
Set obj13 = nothing
Set obj14 = nothing
Set obj15 = nothing
Set obj16 = nothing
Set obj17 = nothing
Set obj18 = nothing
Set obj19 = nothing
Set obj20 = nothing
Set obj21 = nothing
Set obj22 = nothing
Set obj23 = nothing

End Function
%>

<html>
<head>
</head>
<body bgcolor="#C7B29A">
<FORM METHOD=POST ACTION="import_page2.asp">
<INPUT TYPE="submit">
</FORM>
<%

' Grab the HTML Form Fields
'forologoumenou


'what = Upload.Form("eg1")
Season = Upload.Form( "season" )
user_name = Upload.Form( "username" )

Path = "C:\kostasf\dilosi_new\users\" & user_name

AddContactXML path , "" & Season & ".xml"

%>
<html>
<head></head>
<body>
ok
</body>
</html>

Απάντηση

Επιστροφή στο “HTML και XHTML”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 1 επισκέπτης