PHP xml commonly used functions_PHP tutorial
1. DOM function
a. DOMDocument->load()
Function: Load xml file
Usage: DOMDocument->load( string filename )
Parameters: filename, xml file;
Return: TRUE if successful, FALSE if failed.
b. DOMDocument->loadXML()
Function: Load xml code
Usage: DOMDocument->loadXML( string source )
Parameters: source xml code;
Return: TRUE if successful, FALSE if failed.
c. DOMDocument->getElementsByTagName_r()
Function: Search
by tag nameUsage: DOMDocument->getElementsByTagName_r(string name)
Parameters: name, label name;
Return: new DOMNodeList object.
d. DOMDocument->getElementById()
Function: Search
by tag nameUsage: DOMDocument->getElementById(string elementId)
Parameters: elementId, tag id;
Return: new DOMNodeList object.
e.DOMDocument->createElement_x_x()
Function: Create tags
Usage: DOMDocument->createElement_x_x(string name [, string value] )
Parameters: name, tag name, value, only;
Return: new DOMElement object, false on failure.
f. DOMDocument->createTextNode()
Function: Create text node
Usage: DOMDocument->createTextNode(string content)
Parameters: content, content;
Return: new DOMText object, false on failure.
h. DOMDocument->createCDATASection()
Function: Create cdata node
Usage: DOMDocument->createCDATASection( string data)
Parameters: data, content;
Return: new DOMCDATASection object, false on failure.
i. DOMDocument->createAttribute()
Function: Create label attributes
Usage: DOMDocument->createAttribute(string name)
Parameters: name, attribute name;
Return: new DOMAttr object, false on failure.
j.DOMDocument->validate()
Function: Check xml code
Usage: DOMDocument->validate()
Parameters: None
Return: TRUE if successful, FALSE if failed.
k、DOMDocument->save()
Function: Save xml code to xml file
Usage: DOMDocument->save(string filename)
Parameters: filename, xml file;
Return: Returns the xml character length if successful, false if failed.
l. DOMDocument->saveXML()
Function: Save xml code
Usage: DOMDocument->saveXML([DOMNode node [, int options]])
Parameters: node, DOMNode;
Return: Return xml if successful, false if failed.
m、DOMElement->hasAttribute()
Function: Detect whether the attribute exists
Usage: DOMElement->hasAttribute(string name)
Parameters: name, attribute name;
Return: TRUE if successful, FALSE if failed.
n. DOMElement->getAttribute()
Function: Get attribute value
Usage: DOMElement->getAttribute(string name)
Parameters: name, attribute name;
Return: The attribute value is returned on success, and empty on failure.
o.DOMElement->getAttribute()
Function: Get attribute value
Usage: DOMElement->getAttribute(string name)
Parameters: name, attribute name;
Return: The attribute value is returned on success, and empty on failure.
p、DOMElement->setAttribute()
Function: Set attribute value
Usage: DOMElement->setAttribute(string name, string value)
Parameters: name, attribute name; value, attribute value
Return: TRUE if successful, FALSE if failed.
q、DOMNode->appendChild()
Function: Link child nodes to parent nodes
Usage: DOMNode->appendChild(DOMNode newnode)
Parameters: newnode, new node;
Return: Return a new node if successful, return empty if failed.
r、DOMNode->hasAttributes()
Function: Check whether there are attributes
Usage: DOMNode->hasAttributes( )
Parameters: None
Return: TRUE if successful, FALSE if failed.
s, DOMNode->hasChildNodes()
Function: Check whether there are child nodes
Usage: DOMNode->hasChildNodes()
Parameters: None
Return: TRUE if successful, FALSE if failed.
t、DOMNode->insertBefore()
Function: Insert the child node into the DOM tree in front of a certain node
Usage: DOMNode->insertBefore(DOMNode newnode [, DOMNode refnode] )
Parameters: newnode, new node; refnode, reference node
Return: Returns a new node if successful, returns empty if failed.
u. DOMNode->removeChild()
Function: Delete child nodes
Usage: DOMNode->removeChild(DOMNode oldnode)
Parameters: oldnode, child node;
Return: Returns child nodes on success, returns empty on failure.
v. DOMNode->replaceChild()
Function: Update child nodes
Usage: DOMNode->replaceChild(DOMNode newnode, DOMNode oldnode)
Parameters: newnode, new node; oldnode, old node
Return: Return oldnode on success, empty on failure.
————————-DOMNode attribute————————————–
a. DOMNode->nodeType
Function: Get node type
b. DOMNode->nodeName
Function: Get node name
c. DOMNode->nodeValue
Function: Get node content
d. DOMNode->textContent
Function: Get node content
e. DOMNode->parentNode
Function: Get the parent node of the node
f. DOMNode->childNodes
Function: Get node child nodes
g、DOMNode->firstChild
Function: Get the first child node of the node
h、DOMNode->lastChild
Function: Get the last child node of the node
2. XMLReader
a. XMLReader::XML
Function: Load xml string
Usage: XMLReader::xml(string source [, string encoding [, int options]] )
Parameters: source, xml string; encoding, document encoding or NULL
Return: TRUE if successful, FALSE if failed.
b. XMLReader::open
Function: Load xml file
Usage: XMLReader::open(string url [, string encoding [, int options]] )
Parameters: url, link to xml; encoding, document encoding or NULL
Return: TRUE if successful, FALSE if failed.
c. XMLReader::read
Function: Read xml and make the parser advance to the next tag
Usage: XMLReader::read(), traverse the entire document in a while loop
Parameter: NULL
Return: TRUE if successful, FALSE if failed.
d. XMLReader::getAttribute
Function: Get attributes
Usage: XMLReader::getAttribute(string name)
Parameters: name, attribute name
Return: Returns the attribute value if successful, returns FALSE if failed.
e. XMLReader::isValid
Function: Check whether the xml is legal
Usage: XMLReader::isValid()
Parameters: None
Return: true if successful, FALSE if failed.
f. XMLReader::moveToAttribute
Function: Move focus to the pointed attribute
Usage: XMLReader::moveToAttribute(string name)
Parameters: name, attribute name
Return: true if successful, FALSE if failed.
g、XMLReader::moveToFirstAttribute
Function: Move focus to the first attribute
Usage: XMLReader::moveToFirstAttribute()
Parameters: None
Return: true if successful, FALSE if failed.
h、XMLReader::moveToNextAttribute
Function: Move focus to the next attribute
Usage: XMLReader::moveToNextAttribute()
Parameters: None
Return: true if successful, FALSE if failed.
i. XMLReader::moveToElement
Function: Move focus to the current attribute of the parent node
Usage: XMLReader::moveToElement()
Parameters: None
Return: true if successful, FALSE if failed.
j、XMLReader::close
Function: Close xml input
Usage: XMLReader::close()
Parameters: None
Return: true if successful, FALSE if failed.
——————-Constant————————–
XMLReader::NONE = 0 ;
XMLReader::ELEMENT = 1 ;
XMLReader::ATTRIBUTE = 2 ;
XMLReader::TEXT = 3;
XMLReader::CDATA = 4 ;
XMLReader::ENTITY_REF = 5 ;
XMLReader::ENTITY = 6 ;
XMLReader::PI = 7 ;
XMLReader::COMMENT = 8 ;
XMLReader::DOC = 9 ;
XMLReader::DOC_TYPE = 10;
XMLReader::DOC_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::DEFAULTATTRS = 2;
XMLReader::VALIDATE = 3 ;
XMLReader::SUBST_ENTITIES = 4;
————————Properties——————————–
a. XMLReader->attributeCount ;
Function: Number of attributes
b. XMLReader->baseURI;
Function: node url
c. XMLReader->depth ;
Function: The number of layers of the node tree
d. XMLReader->hasAttributes;
Function: Check whether there are attributes
e. XMLReader->hasValue;
Function: Whether it has value
f. XMLReader->isEmptyElement;
Function: Whether it is an empty tag
g、XMLReader->localName;
Function: Label inside the label
h、XMLReader->name ;
Function: Tag name
i. XMLReader->nodeType;
Function: Node type
j、XMLReader->value ;
Function: Node text content
3. XMLWriter
a. XMLWriter::openURI
Function: Create a new XMLWriter from the url output code
Usage: XMLWriter::openURI(string uri)
Parameters: url xml address
Return: true if successful, FALSE if failed.
b. XMLWriter::setIndentString
Function: Set the indent character
Usage: XMLWriter::setIndentString(string indentString)
Parameter: indentString indent character
Return: true if successful, FALSE if failed.
c. XMLWriter::setIndent
Function: Set the indent switch
Usage: XMLWriter::setIndent(bool indent)
Parameter: indent whether to indent or not
Return: true if successful, FALSE if failed.
d. XMLWriter::startDocument
Function: Set the document start tag
Usage: XMLWriter::startDocument( [string version [, string encoding [, string standalone]]] )
Parameters: version, version; encoding, encoding; standalone, independent
Return: true if successful, FALSE if failed.
e. XMLWriter::endDocument
Function: Set the document end tag
Usage: XMLWriter::endDocument( )
Parameters: None
Return: true if successful, FALSE if failed.
f. XMLWriter::startDTD
Function: Set the dtd start tag
Usage: XMLWriter::startDTD( string qualifiedName [, string publicId [, string systemId]] )
Parameters: qualifiedName, name; publicId, piublic; systemId, system
Return: true if successful, FALSE if failed.
g、XMLWriter::endDTD
Function: Set the dtd end tag
Usage: XMLWriter::endDTD()
Parameters: None
Return: true if successful, FALSE if failed.
h、XMLWriter::startElement
Function: Set the start tag
Usage: XMLWriter::startElement(string name)
Parameters: name, label name
Return: true if successful, FALSE if failed.
i. XMLWriter::endElement
Function: Set the closing tag
Usage: XMLWriter::endElement()
Parameters: None
Return: true if successful, FALSE if failed.
j、XMLWriter::startCData
Function: Set the start tag
Usage: XMLWriter::startCData()
Parameters: None
Return: true if successful, FALSE if failed.
k、XMLWriter::endCData
Function: Set the closing tag
Usage: XMLWriter::endCData ()
Parameters: None
Return: true if successful, FALSE if failed.
l. XMLWriter::writeAttribute
Function: Write tag attributes
Usage: XMLWriter::writeAttribute (string name, string value)
Parameters: name, attribute name; value, attribute value
Return: true if successful, FALSE if failed.
m、XMLWriter::writeElement
Function: Write tag attributes
Usage: XMLWriter::writeElement (resource xmlwriter, string name, string content)
Parameters: xmlwriter, xml resource; name, tag name; value, text value
Return: true if successful, FALSE if failed.
n. XMLWriter::writeCData
Function: Write tag attributes
Usage: XMLWriter::writeCData (resource xmlwriter, string content)
Parameters: xmlwriter, xml resource; value, text value
Return: true if successful, FALSE if failed.
o、XMLWriter::text
Function: Write text
Usage: XMLWriter::text (string content)
Parameters: content, text value
Return: true if successful, FALSE if failed.
p、XMLWriter::flush
Function: Clear cache
Usage: XMLWriter::flush ( )
Parameters: None
Return: true if successful, FALSE if failed.

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.