亚洲综合原千岁中文字幕_国产精品99久久久久久久vr_无码人妻aⅴ一区二区三区浪潮_成人h动漫精品一区二区三

主頁 > 知識庫 > 給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麻豆国产福利精品| 国产国语在线播放视频| 日韩综合| 精品国产一区二区三区免费 | 成人免费福利片在线观看| 亚洲第一页色| 久久精品免视看国产明星| 韩国三级香港三级日本三级la | 日本伦理黄色大片在线观看网站| 国产一区二区精品在线观看| 麻豆网站在线看| 国产视频一区二区三区四区| 999精品影视在线观看| 韩国三级香港三级日本三级la | 国产一区二区高清视频| 你懂的国产精品| 亚洲精品影院| 久久精品道一区二区三区| 久久久成人影院| 成人在免费观看视频国产| 欧美a级片免费看| 中文字幕一区二区三区 精品| 久草免费在线色站| 久久精品道一区二区三区| 青青久久国产成人免费网站| 国产91丝袜高跟系列| 欧美激情伊人| 亚飞与亚基在线观看| 免费一级生活片| 精品国产亚洲人成在线| 天天色色网| 日韩在线观看视频网站| 91麻豆国产福利精品| 亚欧乱色一区二区三区| 精品国产三级a∨在线观看| 国产伦久视频免费观看视频| 99色播| 国产美女在线观看| 香蕉视频久久| 麻豆午夜视频| 一级女性大黄生活片免费| 亚洲精品中文一区不卡| 日韩免费片| 精品视频在线看 | 日本在线不卡视频| 精品国产一区二区三区免费 | 国产麻豆精品视频| 999久久久免费精品国产牛牛| 精品视频免费在线| 欧美日本国产| 欧美激情一区二区三区视频| 麻豆午夜视频| 可以免费看污视频的网站| 日本伦理黄色大片在线观看网站| 精品国产一级毛片| 高清一级做a爱过程不卡视频| 91麻豆精品国产综合久久久| 精品国产一级毛片| 天堂网中文在线| 国产成人啪精品视频免费软件| 国产综合成人观看在线| 成人av在线播放| 日本伦理黄色大片在线观看网站| 日韩av成人| 日本免费乱人伦在线观看| 韩国毛片基地| 亚洲精品影院一区二区| 成人av在线播放| 99色播| 欧美一级视| 四虎久久影院| 欧美激情一区二区三区在线播放| 高清一级片| 国产成人精品综合在线| 麻豆网站在线看| 香蕉视频一级| 天天色色网| 九九九国产| 亚洲 国产精品 日韩| 日韩免费片| 91麻豆精品国产自产在线 | 青青青草影院| 九九干| 亚洲 欧美 成人日韩| 精品国产一区二区三区精东影业| 久久精品人人做人人爽97| 尤物视频网站在线观看| 麻豆网站在线看| 亚洲精品久久玖玖玖玖| 久久精品人人做人人爽97| 午夜欧美成人香蕉剧场| 日本伦理网站| 久久精品人人做人人爽97| 欧美爱色| 国产国产人免费视频成69堂| 999久久66久6只有精品| 黄色免费三级| 99热视热频这里只有精品| 国产精品自拍亚洲| 欧美电影免费看大全| 99久久精品国产国产毛片| 国产亚洲免费观看| 天天做人人爱夜夜爽2020毛片| 国产91丝袜高跟系列| 国产欧美精品午夜在线播放| 欧美激情伊人| 精品国产一级毛片| 日本伦理网站| 国产91素人搭讪系列天堂| 亚洲第一页色| 欧美激情一区二区三区视频| 久草免费在线色站| 一级片片| 欧美α片无限看在线观看免费| 成人免费福利片在线观看| 亚州视频一区二区| 青青久久精品国产免费看| 精品国产一区二区三区久久久狼| 韩国毛片基地| 国产91精品露脸国语对白| 高清一级做a爱过程不卡视频| 国产成人精品综合在线| 91麻豆精品国产综合久久久| 免费毛片播放| 日韩中文字幕在线观看视频| 中文字幕一区二区三区 精品| 国产成人精品一区二区视频| 久久久成人影院| 欧美一级视| 亚洲女初尝黑人巨高清在线观看| 国产精品自拍亚洲| 久久国产精品只做精品| 国产成a人片在线观看视频| 国产视频一区二区在线播放| 91麻豆精品国产片在线观看| 99久久精品国产免费| 国产一区二区精品| 九九久久国产精品| 久久精品人人做人人爽97| 久久国产精品只做精品| 九九精品影院| 四虎久久影院| 久久精品人人做人人爽97| 成人影视在线观看| 免费的黄色小视频| 亚洲精品中文一区不卡| 韩国毛片基地| 97视频免费在线观看| 午夜欧美成人香蕉剧场| 国产麻豆精品视频| 日本免费乱人伦在线观看| 日韩在线观看免费| 四虎影视久久久| 国产一级强片在线观看| 午夜在线观看视频免费 成人| 天天做日日干| 欧美国产日韩久久久| 一级毛片看真人在线视频| 二级片在线观看| 亚洲精品久久玖玖玖玖| 成人高清视频免费观看| 国产亚洲免费观看| 欧美另类videosbestsex视频| 午夜在线观看视频免费 成人| 欧美激情伊人| 日韩在线观看视频网站| 欧美夜夜骑 青草视频在线观看完整版 久久精品99无色码中文字幕 欧美日韩一区二区在线观看视频 欧美中文字幕在线视频 www.99精品 香蕉视频久久 | 亚欧乱色一区二区三区| 免费的黄色小视频| 精品视频在线观看视频免费视频| 毛片的网站| 国产视频一区二区在线播放| 国产高清在线精品一区二区| 国产极品精频在线观看| 日本免费乱人伦在线观看| 国产亚洲免费观看| 欧美另类videosbestsex视频| 成人免费福利片在线观看| 精品国产三级a∨在线观看| 欧美一区二区三区性| 亚欧乱色一区二区三区| 国产一区二区精品| 国产精品自拍在线| 91麻豆精品国产片在线观看| 欧美另类videosbestsex视频| 欧美国产日韩久久久| 国产一区二区高清视频| 日韩中文字幕在线观看视频| 深夜做爰性大片中文| 国产极品精频在线观看| 九九久久99| 尤物视频网站在线观看| 午夜久久网| 精品视频在线观看一区二区三区| 欧美另类videosbestsex视频| 成人免费网站视频ww| 欧美激情一区二区三区视频| 国产视频一区二区三区四区| 韩国三级视频网站| 成人免费观看的视频黄页|