Html xml dom Summary

Source: Internet
Author: User

· Concept: javascript uses Dom to delete, modify, and query HTML documents.
Dom, Document Object Model, convert a document into an object.
Built-in document parser in mainstream browsers.

· Rule: the document node corresponding to the HTML document.
When a document object is converted into an HTML Tag, you can perform operations on the HTML document.

· Element node: converts each HTML tag into a corresponding node.
Add: Document. createelement (), appendchild ().
Delete: removeelement ().
Query: getelementsbytagname ().
Getelementbyid ().
Getelementsbyname ().

· Attribute node: Get attribute: getattribute ();
Set attributes: setattribute ();
Delete attribute: removeattribute ();
Create attribute: createattribute ().

· Text node: Create a text node: Document. createtextnode ('asdasd ');
Modify the text node to assign a value to innerhtml again.

· Search node: parentnode firstchild lastchild

· Delete a node: removechild ().

· Image switching: dynamic image Switching
Count ++ plus ++ calculate first and then increase the value

Serial number and synchronous display of images
That is, when the first image is displayed, the serial number 1 is highlighted, and so on.

Click the serial number to display the current image.

· XML is called the World Language of Web and can expand the extensive make language of the emerging markup language.

· Purpose: store and transmit data

· Syntax rules: XML or original JSON is used to represent very complex data.
There must be a root element.
Double quotation marks (recommended) are used for attribute values ).
All elements must be closed.
If XML contains special characters, entity reference is required.
& ---- & Amp '---- & apos "---- & quot

· PHP operation XML: Dom parsing: converts XML documents into objects that can be operated by PHP. Domdocument operates on the entire node tree, domelement operates on a certain element node in the DOM node tree, and domnodelist operates on the collection of certain elements in the DOM node tree.

· VaR _ dump: return data type

· Operation procedure: instantiate the currently required object.
Load the XML document.
Find the element by Tag name.
Use the item () method of the domnodelist object to obtain a node based on the index.
If there are child elements below, continue to call getelementbytagname for searching.
Finally, obtain the desired value through nodevalue.

· Create an XML file using PHP: Create a node in the entire document.
Add content to the new node.
Determine the node location
Save using the Save method.

· $ Doc-> formatoutput = true;
Visualize the written code (level-1 structure display)
However, visualization is not recommended ($ doc-> formatoutput = false; is recommended ;)

· No matter whether it is an element node or an attribute node, the location of the node is not determined during creation. Therefore, the domdocument object is created and its location is determined after creation.

· Header ("Content-Type: text/html; charset = UTF-8 ");
Tell the browser that the text I sent you is encoded as UTF-8 for checking and receiving

 

·

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.