A collection of common functions for PHP XML _php tutorial

Source: Internet
Author: User
Tags cdata
1. DOM functions

A, Domdocument->load ()

Role: Loading an XML file

Usage: domdocument->load (string filename)

Parameters: Filename,xml file;

Returns: TRUE if successful, or FALSE if unsuccessful.

B, Domdocument->loadxml ()

Role: Loading XML code

Usage: Domdocument->loadxml (string source)

Parameters: source XML code;

Returns: TRUE if successful, or FALSE if unsuccessful.

C, Domdocument->getelementsbytagname_r ()

Function: Search by tag name

Usage: Domdocument->getelementsbytagname_r (string name)

Parameters: Name, tag names;

Returns: The new Domnodelist object.

D, Domdocument->getelementbyid ()

Function: Search by tag name

Usage: Domdocument->getelementbyid (string elementid)

Parameters: ElementID, tag ID;

Returns: The new Domnodelist object.

E, domdocument->createelement_x_x ()

Role: Create labels

Usage: domdocument->createelement_x_x (string name [, String value])

Parameters: Name, tag names, value, only;

Returns: The new DomElement object with a failure of false.

F, Domdocument->createtextnode ()

Role: Creating a text node

Usage: Domdocument->createtextnode (string content)

Parameters: content, contents;

Returns: The new Domtext object with a failure of false.

H, Domdocument->createcdatasection ()

Role: Creating CDATA Nodes

Usage: domdocument->createcdatasection (string data)

Parameters: data, content;

Returns: The new Domcdatasection object with a failure of false.

I, Domdocument->createattribute ()

Role: Create Tag Properties

Usage: Domdocument->createattribute (string name)

Parameters: Name, property names;

Returns: The new Domattr object with a failure of false.

J, Domdocument->validate ()

Role: Validate XML code

Usage: domdocument->validate ()

Parameters: None

Returns: TRUE if successful, or FALSE if unsuccessful.

K, Domdocument->save ()

Role: Save XML code to XML file

Usage: domdocument->save (string filename)

Parameters: Filename,xml file;

Returned: The XML character length was returned successfully, and the failure returned false.

L, Domdocument->savexml ()

Role: Saving XML code

Usage: domdocument->savexml ([Domnode node [, int options]])

Parameters: Node,domnode;

Returned: The XML returned successfully, and the failure returned false.

M, Domelement->hasattribute ()

Role: Detecting whether a property exists

Usage: Domelement->hasattribute (string name)

Parameters: Name, property names;

Returns: TRUE if successful, or FALSE if unsuccessful.

N, Domelement->getattribute ()

Function: Gets the property value

Usage: Domelement->getattribute (string name)

Parameters: Name, property names;

Returned: The property value was returned successfully, and the failure returned null.

O, Domelement->getattribute ()

Function: Gets the property value

Usage: Domelement->getattribute (string name)

Parameters: Name, property names;

Returned: The property value was returned successfully, and the failure returned null.

P, Domelement->setattribute ()

Role: Setting Property values

Usage: Domelement->setattribute (string name, String value)

Parameters: Name, property name, value, property value

Returns: TRUE if successful, or FALSE if unsuccessful.

Q, Domnode->appendchild ()

Role: Link a child node to the parent node

Usage: domnode->appendchild (Domnode newnode)

Parameters: NewNode, new node;

Returned: The new node was successfully returned, and the failure returned null.

R, Domnode->hasattributes ()

Role: Checking for attributes

Usage: domnode->hasattributes ()

Parameters: None

Returns: TRUE if successful, or FALSE if unsuccessful.

S, Domnode->haschildnodes ()

Role: Detects if there are child nodes

Usage: domnode->haschildnodes ()

Parameters: None

Returns: TRUE if successful, or FALSE if unsuccessful.

T, Domnode->insertbefore ()

Function: Inserts a node into the DOM tree, positioned before a node

Usage: Domnode->insertbefore (Domnode newnode [, Domnode Refnode])

Parameters: NewNode, new Node;refnode, reference node

Returned: Successfully returned new node, failed to return null.

U, Domnode->removechild ()

Role: Delete child nodes

Usage: domnode->removechild (domnode OldNode)

Parameters: OldNode, sub-node;

Return: Successfully returned a child node, failed to return null.

V, Domnode->replacechild ()

Role: Update child nodes

Usage: domnode->replacechild (domnode newnode, Domnode OldNode)

Parameters: NewNode, new Node;oldnode, old node

Return: OldNode returned successfully, failed to return null.

————————-Domnode Property ———————————— –

A, Domnode->nodetype

Function: Gets the node type

B, Domnode->nodename

Role: Gets the node name

C, Domnode->nodevalue

Role: Get node content

D, Domnode->textcontent

Role: Get node content

E, Domnode->parentnode

Function: Gets the node parent node

F, Domnode->childnodes

Role: Get node nodes

G, Domnode->firstchild

Function: Gets the first child node of the node

H, Domnode->lastchild

Function: Gets the last child node of a node

2, XMLReader

A, Xmlreader::xml

Role: Loading XML strings

Usage: xmlreader::xml (string source [, string encoding [, int options]])

Parameters: Source,xml string;encoding,document encoding or NULL

Returns: TRUE if successful, or FALSE if unsuccessful.

B, Xmlreader::open

Role: Loading an XML file

Usage: xmlreader::open (string URL [, string encoding [, int options]])

Parameters: URL, link to XML, encoding,document encoding or NULL

Returns: TRUE if successful, or FALSE if unsuccessful.

C, Xmlreader::read

Function: Reads the XML and advances the parser to the next tag

Usage: xmlreader::read (), traversing the entire document in the while loop

Parameters: NULL

Returns: TRUE if successful, or FALSE if unsuccessful.

D, Xmlreader::getattribute

Role: Get Properties

Usage: Xmlreader::getattribute (string name)

Parameter: Name, property name

Returns: Returns the property value if successful, or FALSE if it fails.

E, Xmlreader::isvalid

Role: Verifying that XML is legitimate

Usage: xmlreader::isvalid ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

F, Xmlreader::movetoattribute

Action: Moves the focus to the indicated attribute

Usage: Xmlreader::movetoattribute (string name)

Parameter: Name, property name

Returns: True if successful, or FALSE if unsuccessful.

G, Xmlreader::movetofirstattribute

Action: Moves the focus to the first attribute

Usage: Xmlreader::movetofirstattribute ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

H, Xmlreader::movetonextattribute

Action: Move focus to the next attribute

Usage: Xmlreader::movetonextattribute ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

I, xmlreader::movetoelement

Action: Move focus to parent node's current property

Usage: xmlreader::movetoelement ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

J, Xmlreader::close

Function: Turn off XML input

Usage: xmlreader::close ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

———————-Constant ———————— –

Xmlreader::none = 0;

Xmlreader::element = 1;

Xmlreader::attribute = 2;

Xmlreader::text = 3;

Xmlreader::cdata = 4;

Xmlreader::entity_ref = 5;

Xmlreader::entity = 6;

XMLReader::P i = 7;

Xmlreader::comment = 8;

XMLReader::D oc = 9;

XMLReader::D oc_type = 10;

XMLReader::D oc_fragment = 11;

Xmlreader::notation = 12;

Xmlreader::whitespace = 13;

Xmlreader::significant_whitespace = 14;

Xmlreader::end_element = 15;

xmlreader::end_entity = 16;

Xmlreader::xml_declaration = 17;

XMLREADER::LOADDTD = 1;

XMLReader::D efaultattrs = 2;

Xmlreader::validate = 3;

Xmlreader::subst_entities = 4;

———————— Property —————————— –

A, xmlreader->attributecount;

Function: Number of attributes

b, Xmlreader->baseuri;

Function: URL of the node

C, xmlreader->depth;

Role: Number of layers in a node tree

D, Xmlreader->hasattributes;

Role: Detecting whether there are attributes

E, Xmlreader->hasvalue;

Function: Whether there is a value

F, xmlreader->isemptyelement;

Function: Whether it is an empty label

G, Xmlreader->localname;

Function: Label Internal clear

h, Xmlreader->name;

Role: Label name

I, Xmlreader->nodetype;

Role: Node type

J, Xmlreader->value;

Function: Node text content

3, XMLWriter

A, Xmlwriter::openuri

Role: Create a new XmlWriter from the URL output code

Usage: Xmlwriter::openuri (string uri)

Parameters: URL XML address

Returns: True if successful, or FALSE if unsuccessful.

B, xmlwriter::setindentstring

Function: Set indent characters

Usage: xmlwriter::setindentstring (string indentstring)

Parameter: indentstring indent character

Returns: True if successful, or FALSE if unsuccessful.

C, xmlwriter::setindent

Function: Set indent switch

Usage: xmlwriter::setindent (bool indent)

Parameter: Indent indent or not

Returns: True if successful, or FALSE if unsuccessful.

D, Xmlwriter::startdocument

Role: Set the document Start tab

Usage: xmlwriter::startdocument ([String version [, string encoding [, string standalone]])

Parameters: Version, edition, encoding, encoding; standalone, Independent

Returns: True if successful, or FALSE if unsuccessful.

E, xmlwriter::enddocument

Role: Set document END tag

Usage: xmlwriter::enddocument ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

F, Xmlwriter::startdtd

Role: Set the DTD start tag

Usage: XMLWRITER::STARTDTD (string QualifiedName [, String publicid [, String SystemID])

Parameter: qualifiedname, name; Publicid,piublic;systemid,system

Returns: True if successful, or FALSE if unsuccessful.

G, XMLWRITER::ENDDTD

Role: Set the DTD end tag

Usage: XMLWRITER::ENDDTD ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

H, Xmlwriter::startelement

Role: Set start tag

Usage: xmlwriter::startelement (string name)

Arguments: Name, label name

Returns: True if successful, or FALSE if unsuccessful.

I, xmlwriter::endelement

Function: Set end tag

Usage: xmlwriter::endelement ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

J, Xmlwriter::startcdata

Role: Set start tag

Usage: xmlwriter::startcdata ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

K, Xmlwriter::endcdata

Function: Set end tag

Usage: xmlwriter::endcdata ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

L, Xmlwriter::writeattribute

Role: Write Tag properties

Usage: Xmlwriter::writeattribute (string name, String value)

Parameters: Name, property name, value, property value

Returns: True if successful, or FALSE if unsuccessful.

M, xmlwriter::writeelement

Role: Write Tag properties

Usage: xmlwriter::writeelement (Resource XMLWriter, string name, string content)

Parameters: Xmlwriter,xml resource; name, tag name; value, text value

Returns: True if successful, or FALSE if unsuccessful.

N, Xmlwriter::writecdata

Role: Write Tag properties

Usage: Xmlwriter::writecdata (resource XMLWriter, string content)

Parameters: Xmlwriter,xml resource; value, text value

Returns: True if successful, or FALSE if unsuccessful.

O, Xmlwriter::text

Function: Write text

Usage: Xmlwriter::text (string content)

Parameters: Content, text value

Returns: True if successful, or FALSE if unsuccessful.

P, Xmlwriter::flush

Role: Emptying the cache

Usage: Xmlwriter::flush ()

Parameters: None

Returns: True if successful, or FALSE if unsuccessful.

http://www.bkjia.com/PHPjc/372009.html www.bkjia.com true http://www.bkjia.com/PHPjc/372009.html techarticle 1. DOM function A, domdocument-load () function: Load XML File Usage: domdocument-load (string filename) parameter: Filename,xml file; Returns: TRUE if successful Failed ...

  • Related Article

    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.