当前位置: 移动技术网 > IT编程>开发语言>.net > 将HTML表单数据存储为XML格式 - 1

将HTML表单数据存储为XML格式 - 1

2019年01月14日  | 移动技术网IT编程  | 我要评论

电影爱欲狂潮,重庆官方微博,李志希微博

如你熟知asp,xml(标准化越来越近了)和html4。0,请读下列示例

将表单数据存为xml(标准化越来越近了)格式

  通常的,asp中表单提交的数据一般被写入。然而,如果你想让发送数据更为简便易行,那么,可以将它书写为
xml(标准化越来越近了)文件格式。这种方式对于在web上收集的数据更为有用。因为xml(标准化越来越近了)对于所用平台来说非常的简便,所以用不着转换数据格
式。

  将提交的数据写为xml(标准化越来越近了)文档,则需要通过microsoft xml(标准化越来越近了)dom object创建一个新的xml(标准化越来越近了)文档。microsoft xml(标准化越来越近了)dom object
拥有一个可扩展对象库,通过它可以创建elements,attributes以及values,通过创建的这些项目则可以组成xml(标准化越来越近了)文档。我
无法将整个目标模型做个完整的介绍,因为它所包含的内容太广泛,对于将建成的网站来说,目标模型甚至通过自身也能
组建一个相对完整的部份。

  在xml(标准化越来越近了)dom object被创建出来之后,通过创建目标(此目标是关于组成xml(标准化越来越近了)文档中每一层的elements而言)xml(标准化越来越近了)的结构会
被演示出来。接下来,会举例说明xml(标准化越来越近了)dom是怎样被创建出来的。创建root element之后,将它附加在xml(标准化越来越近了)dom文件上。然后
创建child elements并附加在root element上,最后存储文档。

演示microsoft xml(标准化越来越近了)dom 对象

<%

dim objdom
dim objroot
dim objchild1
dim objchild2
dim objpi

" xml(标准化越来越近了)dom 对象使用server对象的createobject方法创建
set objdom = server.createobject("microsoft.xml(标准化越来越近了)dom")
"使用xml(标准化越来越近了)dom的createelemnet方法创建一个ixml(标准化越来越近了)domelement对象。
"createelemnet方法又一个string参数,这个string 表示该element的名称。
返回值被传递到objroot变量。objroot表示xml(标准化越来越近了)文档的根元素.。

set objroot = objdom.createelement("rootelement")

"use the appendchild method of the xml(标准化越来越近了)dom object to add the objroot
"element reference to the xml(标准化越来越近了) document.

objdom.appendchild objroot

"now, following the same steps, you will create references to the
"child elements for the xml(标准化越来越近了) document. the only difference is, when the
"child elements are appended to the document, you will call the
"appendchild method of the ixml(标准化越来越近了)domelement object rather than the
"appendchild method of the xml(标准化越来越近了)dom object. by using the ixml(标准化越来越近了)domelement
"to append the children, you are differentiating (and applying tiered
"structure to) the child elements from the root element.

set objchild1 = objdom.createelement("childelement1")
objroot.appendchild objchild1
set objchild1 = objdom.createelement("childelement2")
objroot.appendchild objchild2

"the final step to take care of before saving this document is to add
"an xml(标准化越来越近了) processing instruction. this is necessary so that xml(标准化越来越近了) parsers
"will recognize this document as an xml(标准化越来越近了) document.

set objpi = objdom.createprocessinginstruction("xml(标准化越来越近了)","vertsion="1.0"")

"call the insertbefore method of the xml(标准化越来越近了)dom object in order to insert
"the processing instruction before the root element (the zero element
"in the xml(标准化越来越近了)dom childnodes collection).

objdom.insertbefore objpi, objdom.childnodes(0)

"calling the save method of the xml(标准化越来越近了)dom object will save this xml(标准化越来越近了)
"document to your disk drive. in this case, the document will be saved
"to the "c:" drive and will be named "myxml(标准化越来越近了)doc.xml(标准化越来越近了)". when saving an
"xml(标准化越来越近了) document, if the file does not exist, it will be created. if it
"does exist, it will be overwritten.

objdom.save "c:myxml(标准化越来越近了)doc.xml(标准化越来越近了)"

%>


如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网