分享一个jscript与vbscript操作XML元素属性的方法
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中文网其他相关文章!

热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

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

本文解释了用于Web内容管理的原子出版协议(ATOMPUB)。 它使用HTTP方法(获取,发布,PUT,删除)详细介绍了用于内容创建,检索,更新和删除的原子格式。 本文还讨论了Atompub

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

手机XML转PDF的速度取决于以下因素:XML结构的复杂性手机硬件配置转换方法(库、算法)代码质量优化手段(选择高效库、优化算法、缓存数据、利用多线程)总体而言,没有绝对的答案,需要根据具体情况进行优化。

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

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

本文详细介绍了针对未经授权访问的RSS供给。 它检查了各种方法,包括HTTP身份验证,具有速率限制的API密钥,HTTPS和内容混淆(灰心)。 最佳实践涉及IP限制,转换

本文详细介绍了为数据一致性创建自定义XML词汇(schemas)。 它涵盖定义范围,识别实体和属性,设计XML结构,选择模式语言(XSD或放松NG),模式开发,测试
