好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > JavaScript生成xml

JavaScript生成xml

熱門標簽:高德地圖地圖標注服務中心 南寧網絡外呼系統運營商 400電話辦理包年 微信地圖標注合并了 如何修改多個百度地圖標注 本地電話機器人 東營電銷 隨州外呼調研系統 r語言數據可視化地圖標注
復制代碼 代碼如下:

function XMLWriter()
{
    this.XML=[];
    this.Nodes=[];
    this.State="";
    this.FormatXML = function(Str)
    {
        if (Str)
            return Str.replace(//g, "").replace(/\"/g, "quot;").replace(//g, "lt;").replace(/>/g, "gt;");
        return ""
    }
    this.BeginNode = function(Name)
    {
        if (!Name) return;
        if (this.State=="beg") this.XML.push(">");
        this.State="beg";
        this.Nodes.push(Name);
        this.XML.push(""+Name);
    }
    this.EndNode = function()
    {
        if (this.State=="beg")
        {
            this.XML.push("/>");
            this.Nodes.pop();
        }
        else if (this.Nodes.length>0)
            this.XML.push("/"+this.Nodes.pop()+">");
        this.State="";
    }
    this.Attrib = function(Name, Value)
    {
        if (this.State!="beg" || !Name) return;
        this.XML.push(" "+Name+"=\""+this.FormatXML(Value)+"\"");
    }
    this.WriteString = function(Value)
    {
        if (this.State=="beg") this.XML.push(">");
        this.XML.push(this.FormatXML(Value));
        this.State="";
    }
    this.Node = function(Name, Value)
    {
        if (!Name) return;
        if (this.State=="beg") this.XML.push(">");
        this.XML.push((Value=="" || !Value)?""+Name+"/>":""+Name+">"+this.FormatXML(Value)+"/"+Name+">");
        this.State="";
    }
    this.Close = function()
    {
        while (this.Nodes.length>0)
            this.EndNode();
        this.State="closed";
    }
    this.ToString = function(){return this.XML.join("");}
}



XMLWriter 有以下幾個方法:

BeginNode (Name) 
EndNode () 
Attrib (Name, Value) 
WriteString (Value) 
Node (Name, Value) 
Close () 
ToString () 
BeginNode 輸出一個標簽:

XML.BeginNode(“Foo”);

XML.BeginNode(“Foo”);
XML.Attrib(“Bar”, “Some Value”);

WriteString 方法:

XML.Node(“MyNode”, “My Value”);
//Produces: MyNode>My Value/MyNode>

XML.BeginNode(“Foo”);
XML.WriteString(“Hello World”);
XML.EndNode();
//Produces Foo>Hello World/Foo>

Node 方法:
XML.EndNode();
//Produces: Foo Bar=”Some Value” />

 

eg:
復制代碼 代碼如下:

function WriteTest()
        {
            try
            {
                var XML=new XMLWriter();
                XML.BeginNode("Example");
                XML.Attrib("SomeAttribute", "And Some Value");
                XML.Attrib("AnotherAttrib", "...");
                XML.WriteString("This is an example of the JS XML WriteString method.");
                XML.Node("Name", "Value");
                XML.BeginNode("SubNode");
                XML.BeginNode("SubNode2");
                XML.EndNode();
                XML.BeginNode("SubNode3");
                XML.WriteString("Blah blah.");
                XML.EndNode();
                XML.Close(); // Takes care of unended tags.
                // The replace in the following line are only for making the XML look prettier in the textarea.
                document.getElementById("ExampleOutput").value=XML.ToString().replace(//g,"\n");
            }
            catch(Err)
            {
                alert("Error: " + Err.description);
            }
            return false;
        }


生成的xml為:


Example SomeAttribute="And Some Value" AnotherAttrib="...">This is an example of the JS XML WriteString method.
Name>Value
/Name>
SubNode>
SubNode2/>
SubNode3>Blah blah.
/SubNode3>
/SubNode>
/Example>

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

巨人網絡通訊聲明:本文標題《JavaScript生成xml》,本文關鍵詞  JavaScript,生成,xml,JavaScript,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《JavaScript生成xml》相關的同類信息!
  • 本頁收集關于JavaScript生成xml的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 韩国办公室激情在线观看完整版| 国产美女一区二区三区三区| 麻豆国产AV精品一区| 校花强迫初苞h| 护士的脚奴足奴| 欧美日韩亚洲另类专区| 黑人留学生嗯啊h| 三上悠亚久久| 泷泽萝拉无码AV精品无删减| 亚洲精品一区二区国产精华液| 午夜精品视频在线观看美女| 久久porn| ??老师扒开腿让我c视频| 欧美自偷自拍曰韩另类欧中文字幕| 国产熊片民工壮熊| 91福利刘玥国产在线观看| 一边吃奶一边添p好爽视频第9季| 成人精品女人久久| 国产又粗又猛又爽又黄的小说软件 | 国产日产欧产系列| 免费福利网址| 二次元女趴着扒开屁股动图| 操美女网址| 女生和男生一起相差差差差差| a国产在线| 古装A片一区二区免费看| 2023亚洲色噜噜狠狠网站| 乱人伦老妇女| 久久久久久精品免费免费浪潮av| 黄色污网| 日本xxxxxx| 成人自拍网站| 99精品国产高清一区二区三区| 疯狂做爰又粗又大| 五月婷婷激情六月| 韩漫免费网站成人漫画www| 91麻豆精品国产自产在线观看一区| 免费网站在线观看人数在哪设置| 小雪解开乳罩给老杨摸| 打屁股调教h| 国产欧美久久久久久精品一区二区|