K zit weer vast
XML bestand:
ASP bestand:
gejat van http://www.xml101.com/articles/michael/editingxml/default.asp en een beetje aangepast
Ik heb dus ook een XSL bestand (dank aan mbravenboer) waarin ik een form opmaak met alle item childnodes er in
Waar ik dus uiteindelijk naartoe wilde was dat ie alle velden uit het geposte form opslaat in het xml bestand,dus gewoon de gewijzigde namen enzo.
Maar ik ben al blij als ie alle naam velden in het hele form "hoi" maakt. wat ie dus nu nog niet doet omdat ie een fout geeft: Object variable not set .(k heb al meer foutmeldingen gehad maar dit is de nieuwste
edit: stylesheet erbij gepost!!!!!
XML bestand:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| <?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="elements.xsl"?>
<Myform>
<name>test</name>
<item id="1">
<name>Text1</name>
<type>Text</type>
<value>none</value>
<groupid>none</groupid>
<visible>Y</visible>
<horsize>30</horsize>
<vertsize>0</vertsize>
</item>
<item id="2">
<name>Checkbox2</name>
<type>Checkbox</type>
<value>none</value>
<groupid>none</groupid>
<visible>Y</visible>
<horsize>30</horsize>
<vertsize>0</vertsize>
</item>
<item id="3">
<name>Radio3</name>
<type>Radio</type>
<value>none</value>
<groupid>none</groupid>
<visible>Y</visible>
<horsize>30</horsize>
<vertsize>0</vertsize>
</item>
</Myform> |
ASP bestand:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| <% @LANGUAGE = VBScript%>
<% Option Explicit%>
<%
Dim objDom
Dim objRoot
Dim objField
Dim x
dim strXMLfile
strXMLFile=server.MapPath("test.xml")
set objDOM = Server.CreateObject("Microsoft.XMLDOM")
objDOM.async = false
objDOM.load strXMLFile
'Set the objRoot variable equal to the root element of the
'XML file by calling the documentElement method of the
'objDOM (XMLDOM) object.
Set objRoot = objDom.documentElement
For x = 1 to Request.Form.Count
response.write "stap" & x & "<br />"
If instr(1,Request.Form.Key(x),"btn") = 0 Then
'Set objField variable equal to a field_value element by
'calling the selectSingleNode method of the objRoot
'(documentElement) object. The SelectSingleNode method
'accepts a string parameter for querying the XML document.
'In this case, the current value of the key property of
'the Form Collection is used to find the appropriate
'field_value element (more on this later).
Set objField = objRoot.selectSingleNode("item[@id='"& x &" ']/name")
'objRoot.selectSingleNode("field[@id='" & Request.Form.Key(x) & "']/name")
'Set the text property of the objField (field_value)
'element equal to the value of the current form field.
if objField<>NULL then
objField.Text = "hoi"
end if
End If
Next
'After the XML file has been edited, is must be saved.
objDom.save strXMLFile
'Release all of your object references.
Set objDom = Nothing
Set objRoot = Nothing
Set objField = Nothing
'response.redirect "test.xml"
%> |
gejat van http://www.xml101.com/articles/michael/editingxml/default.asp en een beetje aangepast
Ik heb dus ook een XSL bestand (dank aan mbravenboer) waarin ik een form opmaak met alle item childnodes er in
Waar ik dus uiteindelijk naartoe wilde was dat ie alle velden uit het geposte form opslaat in het xml bestand,dus gewoon de gewijzigde namen enzo.
Maar ik ben al blij als ie alle naam velden in het hele form "hoi" maakt. wat ie dus nu nog niet doet omdat ie een fout geeft: Object variable not set .(k heb al meer foutmeldingen gehad maar dit is de nieuwste
edit: stylesheet erbij gepost!!!!!
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| <?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<HTML>
<head><title>Sample</title></head>
<body>
<form method="post" action="savechanges.asp">
<xsl:apply-templates/>
<br />
<br />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />
</form>
</body>
</HTML>
</xsl:template>
<xsl:template match="item">
<br /><hr /><br />
ID: <xsl:apply-templates select="@id"/>
<div style="background-color:#0099ff; color:#ffffff; padding:2px">
<span style="font-weight:bold; color:#ffffff">
name: <input type="Text" size="10"><xsl:attribute name="id"><xsl:apply-templates select="@id"/></xsl:attribute><xsl:attribute
name="name"><xsl:apply-templates select="name"/><xsl:apply-templates select="@id"/></xsl:attribute><xsl:attribute name="value"><xsl:apply-templates select="name"/></xsl:attribute></input><br />
type: <input type="Text" size="10"><xsl:attribute name="name"><xsl:apply-templates select="type"/><xsl:apply-templates select="@id"/></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="type"/></xsl:attribute></input><br />
value: <input type="Text" size="10"><xsl:attribute name="name"><xsl:apply-templates select="value"/><xsl:apply-
templates select="@id"/></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute></input><br />
groupid: <input type="Text" size="10"><xsl:attribute name="name"><xsl:apply-templates select="groupid"/><xsl:apply-templates
select="@id"/></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="groupid"/></xsl:attribute></input><br />visible: <input type="Text" size="10"><xsl:attribute name="name"><xsl:apply-templates
select="visible"/><xsl:apply-templates select="@id"/></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="visible"/></xsl:attribute></input><br />
horsize: <input type="Text" size="10"><xsl:attribute name="name"><xsl:apply-templates
select="horsize"/><xsl:apply-templates select="@id"/></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="horsize"/></xsl:attribute></input><br />
vertsize: <input type="Text" size="10"><xsl:attribute name="name"><xsl:apply-templates select="vertsize"/><xsl:apply-templates
select="@id"/></xsl:attribute><xsl:attribute name="value"><xsl:value-of select="vertsize"/></xsl:attribute></input><br />
</span>
</div>
</xsl:template>
</xsl:stylesheet> |