搜索
首页后端开发XML/RSS教程分享一个jscript与vbscript操作XML元素属性的方法
分享一个jscript与vbscript操作XML元素属性的方法Apr 26, 2017 pm 01:57 PM
jscriptvbscriptxml操作

jscript与vbscript 操作XML元素属性的代码,需要的朋友可以参考下。

Although attributes belong to a particular element, they are not considered child nodes of element nodes. Instead, they behave more like properties of IXMLDOMElement. 
Most of the methods for working with attributes come from IXMLDOMElement. Attributes can be manipulated in the following ways. 
Directly, through the getAttribute and setAttribute methods of IXMLDOMElement. 
As named IXMLDOMAttribute nodes, with getAttributeNode and setAttributeNode. 
As a set of nodes accessible through the attributes property and returned as an IXMLNamedNodeMap. 
Examples 
JScript 
The following JScript example creates a new document containing a <memo> element, and then creates an attribute named author with a value of "Pat Coleman".

代码如下:

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); var rootElement=xmlDoc.createElement("memo"); rootElement.setAttribute("author", "Pat Coleman"); xmlDoc.appendChild(rootElement); 
VBScript

代码如下:

Set xmlDoc = CreateObject("Msxml2.DOMDocument.3.0") Set rootElement=xmlDoc.createElement("memo") rootElement.setAttribute("author", "Pat Coleman") xmlDoc.appendChild(rootElement) 
If you prefer to work with attribute nodes, you can create the attribute, and then create a text node to store its value. Attribute nodes can only contain text nodes and entity reference nodes. (If you need to create an attribute containing an entity reference, you must use this approach.) Working with attribute nodes requires using the DOMDocument object to create attribute and text (and entity reference, if necessary) nodes before assigning the nodes to the element. JScript The following JScript code uses this approach to perform the same work as the preceding examples, creating a <memo> element with an author attribute holding the value "Pat Coleman".

 代码如下:

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); 
var rootElement=xmlDoc.createElement("memo"); 
var memoAttribute=xmlDoc.createAttribute("author"); 
var memoAttributeText=xmlDoc.createTextNode("Pat Coleman"); 
memoAttribute.appendChild(memoAttributeText); 
rootElement.setAttributeNode(memoAttribute); 
xmlDoc.appendChild(rootElement);

VBScript

 代码如下:

Set xmlDoc = CreateObject("Msxml2.DOMDocument.3.0") 
Set rootElement=xmlDoc.createElement("memo") 
Set memoAttribute=xmlDoc.createAttribute("author") 
Set memoAttributeText=xmlDoc.createTextNode("Pat Coleman") 
memoAttribute.appendChild(memoAttributeText) 
rootElement.setAttributeNode(memoAttribute) 
xmlDoc.appendChild(rootElement)

以上是分享一个jscript与vbscript操作XML元素属性的方法的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
XML修改属性值有何限制XML修改属性值有何限制Mar 03, 2025 pm 05:32 PM

本文详细介绍了修改XML属性值,突出了构成良好的限制,模式/DTD验证和字符编码。 它强调了陷阱,例如不当逃脱和数据类型不匹配,并解决了Securit

XML修改内容会影响性能吗XML修改内容会影响性能吗Mar 03, 2025 pm 05:27 PM

修改XML内容会显着影响应用程序性能,尤其是在大文件的情况下。 解析,DOM操纵,序列化和I/O操作有助于这一点。 优化策略包括使用流解析器,最小化D

如何使用RSS feed进行新闻汇总和内容策划?如何使用RSS feed进行新闻汇总和内容策划?Mar 10, 2025 pm 03:47 PM

本文解释了如何使用RSS feed进行有效的新闻汇总和内容策划。 它详细介绍了使用RSS读取器(例如Feedly和Inoreader),组织供稿以及为目标内容的利用功能的订阅供稿。 利益

XML如何修改大型XML文件XML如何修改大型XML文件Mar 03, 2025 pm 05:31 PM

本文处理有效的大型XML文件修改。 它突出了内存处理的效率低下,主张诸如SAX和Stax解析之类的流媒体方法。 优化策略包括增量解析,优化数据s

如何集成XML和语义Web技术?如何集成XML和语义Web技术?Mar 10, 2025 pm 05:50 PM

本文探讨了集成XML和语义网络技术。 核心问题是将XML的结构化数据映射到RDF三元组,以进行语义互操作性。 最佳实践涉及本体定义,战略映射方法,仔细的ATT

XML修改内容如何进行数据转换XML修改内容如何进行数据转换Mar 03, 2025 pm 05:25 PM

本文详细介绍了XML数据转换方法。 它解决了在XML文档中转换数据格式的挑战,突出了诸如XSLT和流处理之类的有效技术。 本文还涵盖了潜在的陷阱,例如SCH

如何将XML用于医疗保健/财务/等的数据互操作性?如何将XML用于医疗保健/财务/等的数据互操作性?Mar 10, 2025 pm 05:50 PM

本文使用XML详细介绍了数据互操作性,重点是医疗保健和金融。 它涵盖了模式定义,XML文档创建,数据转换,解析和交换机制。钥匙XML标准(HL7,DICOM,FinML,ISO 20022)

如何使用RSS实施内容联合?如何使用RSS实施内容联合?Mar 10, 2025 pm 03:41 PM

本文详细介绍了使用RSS提要实施内容联合的内容。 它涵盖创建RSS提要,识别目标网站,提交提要以及监视效率。 诸如有限控制和丰富媒体支持之类的挑战也是铁饼

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前By尊渡假赌尊渡假赌尊渡假赌
仓库:如何复兴队友
4 周前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版