婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 給XML文檔添加新 ”records”

給XML文檔添加新 ”records”

熱門標簽:本地電話機器人 400電話辦理包年 東營電銷 如何修改多個百度地圖標注 南寧網絡外呼系統運營商 高德地圖地圖標注服務中心 微信地圖標注合并了 隨州外呼調研系統 r語言數據可視化地圖標注
本文所舉的例子與保存HTML格式數據至XML類似。在以往當表格被提交后,我們通常會創建一個新的文檔,現在只要文檔已經存在,那么直接添加就可以了。此種技術的使用與創建基本數據類似。

  在前面的文章里,我已經演示了如何使用XMLDOM。因此,我們可以直接進入本文的示例。

  我們需要考慮的第一件事是我們將用于添加新"記錄"的HTML 表單。在"將HTML表單數據保存至XML"例子中我們已使用過此表單,只是更改了文件名,但代碼是相同的。

  AddContact.html:
復制代碼 代碼如下:

  html>
  head>
   title> Contact Information /title>
  /head>
  body>
   form action="processAdd.asp" method="post"> 
   h3>Enter your contact information/h3> 
   First Name: 
   input type="text" id="firstName" name="firstName">br> Last Name: 
   input type="text" id="lastName" name="lastName">br> Address #1: 
   input type="text" id="address1" name="address1">br> Address #2: 
   input type="text" id="address2" name="address2">br> Phone Number: 
   input type="text" id="phone" name="phone">br> E-Mail: 
   input type="text" id="email" name="email">br> 
   input type="submit" id="btnSub" name="btnSub" value="Submit">br> 
   /form>
  /body>
  /html>

  我們設置此HTML表單是來處理ADD。ASP的。這里的ASP 頁面具有檢測XML.文件及ROLODEX.XML是否存在的功能。如果它們確實存在,ASP則會在文件上附加新的條目,如果文件不存在,則需要創建。 

  Process Add.asp: 
復制代碼 代碼如下:

  %
   '--------------------------------------------------------------------
   'The "addNewContacttoXML" Function accepts two parameters.
   'strXMLFilePath - The physical path where the XML file will be saved.
   'strFileName - The name of the XML file that will be saved.
   '--------------------------------------------------------------------
   Function addNewContacttoXML(strXMLFilePath, strFileName) 
    'Declare local variables. 
    Dim objDom 
    Dim objRoot 
    Dim objRecord 
    Dim objField
    Dim objFieldValue 
    Dim objattID 
    Dim objattTabOrder 
    Dim objPI 
    Dim blnFileExists 
    Dim x 
    'Instantiate the Microsoft XMLDOM. 
    Set objDom = server.CreateObject("Microsoft.XMLDOM") 
    objDom.preserveWhiteSpace = True
    'Call the Load Method of the XMLDOM Object. The Load ethod has a 
    'boolean return value indicating whether or not the file could be 
    'loaded. If the file exists and loads it will return true, otherwise,
    'it will return false.

    blnFileExists = objDom.Load(strXMLFilePath  "\"  strFileName) 

    'Test to see if the file loaded successfully. 
    If blnFileExists = True Then 
     'If the file loaded set the objRoot Object equal to the root element 
     'of the XML document. 
     Set objRoot = objDom.documentElement Else 
     'Create your root element and append it to the XML document. 
     Set objRoot = objDom.createElement("rolodex") 
     objDom.appendChild objRoot
    End If 
     'Create the new container element for the new record. 
     Set objRecord = objDom.createElement("contact") 
     objRoot.appendChild objRecord 
     'Iterate through the Form Collection of the Request Object.
     For x = 1 To Request.Form.Count 
      'Check to see if "btn" is in the name of the form element. If it is, 
      'then it is a button and we do not want to add it to the XML 
      'document". 
      If instr(1,Request.Form.Key(x),"btn") = 0 Then 
       'Create an element, "field". 
       Set objField = objDom.createElement("field") 
       'Create an attribute, "id". 
       Set objattID = objDom.createAttribute("id") 

       'Set the value of the id attribute equal the the name of the current 
       'form field. 
       objattID.Text = Request.Form.Key(x) 
       'The setAttributeNode method will append the id attribute to the 
       'field element. objField.setAttributeNode objattID 
       'Create another attribute, "taborder". This just orders the 
       'elements. 

       Set objattTabOrder = objDom.createAttribute("taborder") 
       
       'Set the value of the taborder attribute. 
       objattTabOrder.Text = x 
       'Append the taborder attribute to the field element. 
       'objField.setAttributeNode objattTabOrder 
       'Create a new element, "field_value".

       Set objFieldValue = objDom.createElement("field_value") 

       'Set the value of the field_value element equal to the value of the 
       'current field in the Form Collection. 

       objFieldValue.Text = Request.Form(x) 

       'Append the field element as a child of the new record container 
       'element, contact. objRecord.appendChild objField 
       'Append the field_value element as a child of the field element.
       objField.appendChild objFieldValue 
      End If 
     Next 

     'Check once again to see if the file loaded successfully. If it did 
     'not, that means we are creating a new document and need to be sure to 
     'insert the XML processing instruction. 

     If blnFileExists = False then 

      '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) 
     End If 

     'Save the XML document.

     objDom.save strXMLFilePath  "\"  strFileName 

     'Release all of your object references. 
     Set objDom = Nothing 

     Set objRoot = Nothing 
     Set objRecord = Nothing 
     Set objField = Nothing 
     Set objFieldValue = Nothing 
     Set objattID = Nothing 
     Set objattTabOrder = Nothing 
     Set objPI = NothingEnd 

    Function
    'Do not break on an error.

    On Error Resume Next

    'Call the addNewContacttoXML function, passing in the physical path to
    'save the file to and the name that you wish to use for the file.

    addNewContacttoXML "c:","rolodex.xml"
    'Test to see if an error occurred, if so, let the user know.
    'Otherwise, tell the user that the operation was successful.

    If err.number > 0 then 
     Response.write("Errors occurred while saving your form submission.")
    Else 
     Response.write("Your form submission has been saved.")
    End If
   %>

如果你已經讀過關于"將HTML 表單數據保存至XML格式"的文章,你會注意到附加到將HTML數據擴展到XML文件的代碼與HTML數據擴展到新文檔的代碼基本上是一致的。但是這里還是有兩個主要的不同點:

   'Call the Load Method of the XMLDOM Object. The Load Method has a 
   'boolean return value indicating whether or not the file could be 
   'loaded. If the file exists and loads it will return true, otherwise, 
   'it will return false. 

   blnFileExists = objDom.Load(strXMLFilePath  "\"  strFileName) 
   
   'Test to see if the file loaded successfully. 

   If blnFileExists = True Then 

    'If the file loaded set the objRoot Object equal to the root element 
    'of the XML document. 

    Set objRoot = objDom.documentElement
   Else 

    'Create your root element and append it to the XML document. 
    Set objRoot = objDom.createElement("contact") 
    objDom.appendChild objRoot 
   End If

  本節的代碼來自addNewContacttoXML 功能。因為我們不可能每次都新建一個文件,所以我們改為保存CONTACT。如果能夠LOAD此文件呢,我們則獲得了這個XML文檔的根元素;如果不能夠呢,那么我們就假設它不存在并創建一個新的要元素并將它附加到XML文檔上。

  另外一個主要區別在于:當我們對文件進行二次檢測,是否成功的LOAD,這樣我們可以決定是否需要加上 一條處理指令。如果文件存在,我們就不需要加上這條指令。但是,如果創建了一個新的文件,那么則一定得加上這條處理指令。

  'Check once again to see if the file loaded successfully. If it did 
  'not, that means we are creating a new document and need to be sure to 
  'insert the XML processing instruction. 

  If blnFileExists = False then 

   '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) 
  End If

  除開以上兩點不同之處外,你可以發現 保存數據至新文件的代碼實際上是與 附加新record至存在文件的代碼是一樣的。我們創建一個新的element, contact CONTAINER,以便能容下每個新添的RECORD。代碼將會在Form Collection of the Request Objec中不斷重復以創建適合的XML節點并將這些節點值設置得與當前Form Field.一樣。

  如以往一樣,我推薦大家復制以上代碼至你的 服務器上并運行。希望以上舉例會對你有所幫助。

標簽:益陽 寧夏 拉薩 宿遷 德州 西雙版納 黃石 果洛

巨人網絡通訊聲明:本文標題《給XML文檔添加新 ”records”》,本文關鍵詞  給,XML,文檔,添加,新,records,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《給XML文檔添加新 ”records”》相關的同類信息!
  • 本頁收集關于給XML文檔添加新 ”records”的相關信息資訊供網民參考!
  • 推薦文章
    婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av
    国产精品美女视频| 一本大道久久a久久精品综合| 蜜桃视频免费观看一区| 91色在线porny| 国产精品视频第一区| 成人免费看的视频| 综合电影一区二区三区| 成人免费高清视频| 国产精品网曝门| 99久久99久久综合| 亚洲欧美日本韩国| 欧美日韩亚洲不卡| 蜜臀国产一区二区三区在线播放 | 在线看国产一区| 亚洲综合一二三区| 91久久香蕉国产日韩欧美9色| 亚洲精品视频在线看| 欧美艳星brazzers| 亚洲一区二区三区美女| 欧美肥妇毛茸茸| 国产在线精品一区在线观看麻豆| 国产亚洲女人久久久久毛片| av毛片久久久久**hd| 亚洲婷婷综合色高清在线| 日韩电影在线免费观看| 欧美成人一级视频| 不卡视频一二三| 亚洲成年人网站在线观看| 久久午夜电影网| 972aa.com艺术欧美| 首页国产丝袜综合| 欧美成人福利视频| 91行情网站电视在线观看高清版| 亚洲一区二区视频| 2020国产精品久久精品美国| 91美女蜜桃在线| 亚洲成av人片| 久久精品夜色噜噜亚洲aⅴ| 粉嫩av亚洲一区二区图片| 午夜av一区二区| 最新不卡av在线| 久久久青草青青国产亚洲免观| 欧美性大战久久久久久久蜜臀| 国产精品资源在线| 欧美aⅴ一区二区三区视频| 亚洲精品国产无天堂网2021| 欧美激情综合五月色丁香| 欧美一区二区三区免费观看视频| 91久久国产综合久久| 99久久久久久| 丁香一区二区三区| 麻豆精品国产传媒mv男同| 亚洲v日本v欧美v久久精品| 一区在线播放视频| 国产日韩精品视频一区| 日韩免费性生活视频播放| 欧美日韩国产综合久久| 欧美日韩一卡二卡| 欧美日韩免费视频| 欧美日韩另类一区| 欧美亚洲日本国产| 欧美色爱综合网| 欧美精品 国产精品| 7777精品伊人久久久大香线蕉经典版下载 | 中文字幕在线不卡视频| 国产喂奶挤奶一区二区三区| 久久亚洲综合色| 欧美电视剧在线观看完整版| 69堂精品视频| 91精品国产综合久久久久久久久久| 欧美性xxxxx极品少妇| 欧美视频一区二区三区四区| 欧美亚洲国产一卡| 欧美日韩在线不卡| 欧美二区在线观看| 日韩欧美一区二区视频| 久久亚洲精品国产精品紫薇| 精品人在线二区三区| 久久久综合精品| 国产精品久久久久久福利一牛影视| 国产精品私人自拍| 一区二区三区视频在线看| 亚洲v中文字幕| 久久99久久精品欧美| 国产一区二区美女诱惑| 99久久婷婷国产精品综合| 在线亚洲欧美专区二区| 日韩欧美国产精品一区| 国产欧美综合在线| 亚洲影院理伦片| 久久99国内精品| eeuss国产一区二区三区| 欧美日韩精品久久久| 精品精品欲导航| 国产精品久久毛片| 亚洲高清视频中文字幕| 国产在线精品一区二区| 一本到高清视频免费精品| 91精品国产高清一区二区三区蜜臀| 久久久久久久久久美女| 亚洲国产精品久久不卡毛片| 国产一区二区调教| 在线观看亚洲一区| 久久精品男人天堂av| 亚洲成人动漫在线免费观看| 成人国产在线观看| 日韩一级二级三级精品视频| 亚洲日本在线a| 国内精品久久久久影院一蜜桃| 91精品1区2区| 国产欧美一区二区精品婷婷| 亚洲综合色成人| 成人午夜碰碰视频| 欧美一卡2卡3卡4卡| 一区二区三区在线视频观看58| 麻豆精品视频在线| 欧美久久久久久久久中文字幕| 国产欧美一区视频| 久久成人免费网| 欧美挠脚心视频网站| 国产精品第四页| 九色综合狠狠综合久久| 日本道精品一区二区三区| 久久久国产一区二区三区四区小说| 亚洲成av人片在线观看无码| 91丝袜美女网| 亚洲色图欧美激情| 国产成人av电影在线观看| 久久综合视频网| 看电视剧不卡顿的网站| 91麻豆精品国产无毒不卡在线观看| 亚洲欧美日韩系列| 成人h精品动漫一区二区三区| 日韩欧美国产综合在线一区二区三区| 亚洲精品视频自拍| 91香蕉视频污| 亚洲欧洲日本在线| 国产精品夜夜嗨| 日韩欧美一区二区三区在线| 日本美女一区二区三区视频| 欧美亚洲国产一区二区三区| 一区二区三区四区乱视频| 99天天综合性| 亚洲乱码中文字幕综合| 欧美午夜一区二区三区 | 国产精品久久国产精麻豆99网站| 久久不见久久见免费视频7| 日韩一区二区视频在线观看| 日韩高清国产一区在线| 欧美精品三级在线观看| 日韩av网站在线观看| 欧美一级精品大片| 久久精品国内一区二区三区| 欧美日韩免费观看一区三区| 一区二区三区欧美久久| 国产成人免费av在线| 日韩一区二区三区av| 视频一区视频二区在线观看| 播五月开心婷婷综合| 国产女主播一区| 成人听书哪个软件好| 欧美日韩一区成人| 亚洲一区二区成人在线观看| 欧美日韩不卡在线| 国产精品1区二区.| 日韩美女久久久| 欧美一卡2卡3卡4卡| 成人精品电影在线观看| 亚洲欧洲综合另类| 欧美精品在线一区二区| 国产一区二区三区日韩| 一区二区三区在线看| 在线观看日韩毛片| 日韩成人午夜精品| 中文字幕第一区综合| 欧美日韩免费不卡视频一区二区三区| 久久国产福利国产秒拍| 国产精品狼人久久影院观看方式| 91麻豆国产自产在线观看| 日韩激情在线观看| 国产无人区一区二区三区| 欧美性猛交xxxx乱大交退制版| 国产揄拍国内精品对白| 中文字幕一区日韩精品欧美| 色婷婷av一区二区三区之一色屋| 美女性感视频久久| 久久嫩草精品久久久久| 日本韩国精品在线| 国产乱对白刺激视频不卡| 亚洲综合一区二区| 欧美韩国日本不卡| 欧美一区二区三区小说| 国产成人99久久亚洲综合精品| 日本中文字幕一区二区有限公司| 中文字幕欧美日韩一区| 欧美一级黄色片| 在线看国产一区| 91精品办公室少妇高潮对白| 国产成人免费视频网站| 国产福利一区二区三区视频在线|