zoukankan      html  css  js  c++  java
  • VBS生成XML文件

    Dim xmlDoc, rootEl, child1, child2, p

    '创建XML文档
    Set xmlDoc = CreateObject("MSXML2.DOMDocument")

    '创建根元素并将之加入文档
    Set rootE1=xmlDoc.createElement("BookStore")
    xmlDoc.appendChild rootE1

    '创建并加入子元素
    Set bookchild1=xmlDoc.createElement("book")
    Set ISDNAttribute=xmlDoc.createAttribute("ISDN")
    ISDNAttribute.text="789456123"
    bookchild1.setAttributeNode ISDNAttribute

    Set bookchild1_title=xmlDoc.createElement("title")
    bookchild1_title.text="C#"
    bookchild1.appendChild bookchild1_title

    Set bookchild1_author=xmlDoc.createElement("author")
    bookchild1_author.text="BXH"
    bookchild1.appendChild bookchild1_author

    Set bookchild1_price=xmlDoc.createElement("Price")
    bookchild1_price.text="29.3"
    bookchild1.appendChild bookchild1_price

    rootE1.appendChild bookchild1

    '创建并加入子元素
    Set bookchild2=xmlDoc.createElement("book")
    Set ISDNAttribute=xmlDoc.createAttribute("ISDN")
    ISDNAttribute.text="789457898"
    bookchild2.setAttributeNode ISDNAttribute

    Set bookchild2_title=xmlDoc.createElement("title")
    bookchild2_title.text="F#"
    bookchild2.appendChild bookchild2_title

    Set bookchild2_author=xmlDoc.createElement("author")
    bookchild2_author.text="mary"
    bookchild2.appendChild bookchild2_author

    Set bookchild2_price=xmlDoc.createElement("Price")
    bookchild2_price.text="78"
    bookchild2.appendChild bookchild2_price

    rootE1.appendChild bookchild2

    '创建 XML processing instruction
    '并把它加到根元素之前
    Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
    xmlDoc.insertBefore p,xmlDoc.childNodes(0)

    '把文件保存到c目录
    xmlDoc.Save "d:\test.xml"

  • 相关阅读:
    CSS清浮动处理(Clear与BFC)
    站点的排名对于站点非常重要
    Jquery插件placeholder的用法
    怎样将程序猿写出来的程序打包成安装包(最简单的)
    几种常见模式识别算法整理和总结
    数组中的跳跃问题
    基于各种浏览器的写法兼容
    cisco(思科)交换机配置篇【两】
    怎么样excel其产生的条形码(10分钟的时间excel)从而出现了条形码
    iOS随机颜色
  • 原文地址:https://www.cnblogs.com/zhangfei/p/2407937.html
Copyright © 2011-2022 走看看