- XML DOM - Accessing
- XML DOM - Navigation
- XML DOM - Traversing
- XML DOM - Loading
- XML DOM - Methods
- XML DOM - Node Tree
- XML DOM - Nodes
- XML DOM - Model
- XML DOM - Overview
- XML DOM - Home
XML DOM Operations
- XML DOM - Clone Node
- XML DOM - Remove Node
- XML DOM - Replace Node
- XML DOM - Add Node
- XML DOM - Create Node
- XML DOM - Set Node
- XML DOM - Get Node
XML DOM Objects
- DOM - DOMException Object
- DOM - XMLHttpRequest Object
- DOM - Comment Object
- DOM - CDATASection Object
- DOM - Attribute Object
- DOM - Element Object
- DOM - Notation Object
- DOM - EntityReference Object
- DOM - Entity Object
- DOM - ProcessingInstruction
- DOM - DocumentType Object
- DOM - DOMImplementation
- DOM - NamedNodeMap Object
- DOM - NodeList Object
- DOM - Node Object
XML DOM Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
XML DOM - Loading
在本章中,我们将研究XML /oding和Parsing。
为了描述APIC提供的接口,W3C使用一个称为“Interface Defin Language (IDL)”的抽象语言。 使用IDL的好处是,开发商学习如何使用DOM,使用其偏好的语言,并且可以很容易地改用另一种语言。
缺点是,由于这是抽象的,因此网络开发商不能直接使用IDL。 由于方案拟定语文之间的差异,它们需要在抽象接口与具体语文之间绘制地图,或使其具有约束力。 DOM被绘制成方案编制语言,如Javascript、Jend、Java、C、C++、PLSQL、Zahur和Perl。
In the following sections and chapters, we will be using Javascript as our programming language to load XML file.
Parser
A parser是软件应用,旨在分析文件,如XML文件,并与信息具体相关。 下表列出了一些基于DOM的教区:
S.No | Parser & Description |
---|---|
1 |
Sun Microsystem's Java AP for XML Parsing (JAXP) |
2 | XML4J IBM(XML4J) |
3 | msxml 微软的XML教区(msxml)版本2.0为因特网探测器。 |
4 | 4 DOM是S 方案拟订语言的一个教区 |
5 | XML:DOM XML:DOM是使用Perl操纵XML文件的一个Perl模块 |
6 | 25. Papa's Xerces Java Parser |
在像DOM这样的植树的APIC中, par子 trav子是XML文件,制造相应的DOM物体。 然后,你可以回击OM结构。
Loading and Parsing XML
在装上XML文件时,XML的内容可以有两种形式:
Directly as XML file
As XML string
Content as XML file
下面举例说明,在XML内容作为XML文件收到时,如何使用Ajax和Javascript(
responseXML 在XML DOM中直接改变XML的内容。
一旦将XML的内容转化为Javagust XML DOM,你就可以通过使用JSDOM方法和财产获取任何XML要素。 我们利用了诸如Nodes、nodeValue和诸如获得ElementsById(ID)、获得ElementsByTagName(tags_name)等多功能。
Execution
Save this file asloadingexample.html and open it in their browser. 您将获得以下产出:

Content as XML string
下面的例子表明,如果将XML的内容作为XML文件接收,如何用Ajax和Javascript装载XML数据。 这里,Ajax功能在XML DOM中获取Xml文档的内容并储存。 一旦制造了DOM物体,就进行平价。
<!DOCTYPE html> <html> <head> <script> // loads the xml string in a dom object function loadXMLString(t) { // for non IE browsers if (window.DOMParser) { // create an instance for xml dom object parser = new DOMParser(); xmlDoc = parser.parseFromString(t,"text/xml"); } // code for IE else { // create an instance for xml dom object xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.loadXML(t); } return xmlDoc; } </script> </head> <body> <script> // a variable with the string var text = "<Employee>"; text = text+"<FirstName>Tanmay</FirstName>"; text = text+"<LastName>Patil</LastName>"; text = text+"<ContactNo>1234567890</ContactNo>"; text = text+"<Email>tanmaypatil@xyz.com</Email>"; text = text+"</Employee>"; // calls the loadXMLString() with "text" function and store the xml dom in a variable var xmlDoc = loadXMLString(text); //parsing the DOM object y = xmlDoc.documentElement.childNodes; for (i = 0;i<y.length;i++) { document.write(y[i].childNodes[0].nodeValue); document.write("<br>"); } </script> </body> </html>
守则的大部分细节载于文字法。
互联网探索者使用ActiveXObject(“Microsoft.XMLDOM”)将XML数据输入OM物体,其他浏览器则使用DOMParser(功能和parseFromString(text, text/xml )方法。
变量text应包含有XML内容的说明。
一旦将XML的内容转化为Javagust XML DOM,你就可以通过使用JS DOM方法和财产获取任何XML要素。 我们利用了DOM特性,例如Nodes,nodeValue。
Execution
Save this file asloadingexample.html and open it in their browser. 你将看到以下产出:

既然我们看到XML的内容如何转化为Javagust XML DOM,那么你现在可以通过使用XML DOM方法获取任何XML要素。
Advertisements