search
HomeBackend DevelopmentXML/RSS TutorialDetailed introduction on how to create DOM and load XML in IE

Introduction

1. Create an instance of XML DOMobject

Microsoft The ActiveXObject class for creating ActiveX objects is introduced in JavaScript, through which instances of XML DOM objects can be created. The code is as follows:

var xmldoc = new ActiveXObject("Microsoft.XMLDOM");

2, Loading XML

Microsoft's XML DOM has two methods of loading XML, namely load() and loadXML().

Method 1:

The load() method is used to load XML files from the server. The syntax format of the load() method is as follows:

xmldoc.load(url);

Parameter description:

xmldoc: is an instance of XML DOM object.

url: is the name of the XML file.

Note: The

load() method can only load files stored on the same server as the page containing JavaScript.

When loading, you can also use synchronous or asynchronous modes. By default, files are loaded in asynchronous mode. If you need to load synchronously, you can set the asyncproperty to false.

When loading a file asynchronously, you also need to use the readyState attribute and onreadystatechangeEvent processingfunction, so as to ensure that other operations are performed after the DOM is fully loaded.

Method 2: The

loadXML() method can directly input XMLstring to the XML DOM, for example:

xmldoc.loadXML("<root><son/></root>");

Second Get XML The root node application of the document

implements the integrated application of XML, DOM and JavaScript in the instance.

First use ActiveXObject to create a Microsoft parser instance, then load the XML document into memory, then use the DOM object to obtain the root node in the XML document (var rootElement = xmldoc.documentElement;), and finally output the root node .

Three codes



获取XML文档的根结点



<script>
var xmldoc = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;);     //创建Microsoft解析器实例
xmldoc.async = false;
xmldoc.load("27_1.xml");  //载入指定的XML文档
var rootElement = xmldoc.documentElement;  //访问元素根节点
document.write(rootElement.nodeName);
</script>

Four running results

Software management system

The above is the detailed content of Detailed introduction on how to create DOM and load XML in IE. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
RSS in XML: Unveiling the Core of Content SyndicationRSS in XML: Unveiling the Core of Content SyndicationApr 22, 2025 am 12:08 AM

The implementation of RSS in XML is to organize content through a structured XML format. 1) RSS uses XML as the data exchange format, including elements such as channel information and project list. 2) When generating RSS files, content must be organized according to specifications and published to the server for subscription. 3) RSS files can be subscribed through a reader or plug-in to automatically update the content.

Beyond the Basics: Advanced RSS Document FeaturesBeyond the Basics: Advanced RSS Document FeaturesApr 21, 2025 am 12:03 AM

Advanced features of RSS include content namespaces, extension modules, and conditional subscriptions. 1) Content namespace extends RSS functionality, 2) Extended modules such as DublinCore or iTunes to add metadata, 3) Conditional subscription filters entries based on specific conditions. These functions are implemented by adding XML elements and attributes to improve information acquisition efficiency.

The XML Backbone: How RSS Feeds are StructuredThe XML Backbone: How RSS Feeds are StructuredApr 20, 2025 am 12:02 AM

RSSfeedsuseXMLtostructurecontentupdates.1)XMLprovidesahierarchicalstructurefordata.2)Theelementdefinesthefeed'sidentityandcontainselements.3)elementsrepresentindividualcontentpieces.4)RSSisextensible,allowingcustomelements.5)Bestpracticesincludeusing

RSS & XML: Understanding the Dynamic Duo of Web ContentRSS & XML: Understanding the Dynamic Duo of Web ContentApr 19, 2025 am 12:03 AM

RSS and XML are tools for web content management. RSS is used to publish and subscribe to content, and XML is used to store and transfer data. They work with content publishing, subscriptions, and update push. Examples of usage include RSS publishing blog posts and XML storing book information.

RSS Documents: The Foundation of Web SyndicationRSS Documents: The Foundation of Web SyndicationApr 18, 2025 am 12:04 AM

RSS documents are XML-based structured files used to publish and subscribe to frequently updated content. Its main functions include: 1) automated content updates, 2) content aggregation, and 3) improving browsing efficiency. Through RSSfeed, users can subscribe and get the latest information from different sources in a timely manner.

Decoding RSS: The XML Structure of Content FeedsDecoding RSS: The XML Structure of Content FeedsApr 17, 2025 am 12:09 AM

The XML structure of RSS includes: 1. XML declaration and RSS version, 2. Channel (Channel), 3. Item. These parts form the basis of RSS files, allowing users to obtain and process content information by parsing XML data.

How to Parse and Utilize XML-Based RSS FeedsHow to Parse and Utilize XML-Based RSS FeedsApr 16, 2025 am 12:05 AM

RSSfeedsuseXMLtosyndicatecontent;parsingtheminvolvesloadingXML,navigatingitsstructure,andextractingdata.Applicationsincludebuildingnewsaggregatorsandtrackingpodcastepisodes.

RSS Documents: How They Deliver Your Favorite ContentRSS Documents: How They Deliver Your Favorite ContentApr 15, 2025 am 12:01 AM

RSS documents work by publishing content updates through XML files, and users subscribe and receive notifications through RSS readers. 1. Content publisher creates and updates RSS documents. 2. The RSS reader regularly accesses and parses XML files. 3. Users browse and read updated content. Example of usage: Subscribe to TechCrunch's RSS feed, just copy the link to the RSS reader.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools