PHP 5 SimpleXML Functions

## PHP Basic

PHP HOME PHP Intro PHP Install PHP Syntax PHP Variables PHP Echo / Print PHP Data Types PHP String Functions PHP Constants PHP Operators PHP If...Else...Elseif PHP Switch PHP While Loops PHP For Loops PHP Functions PHP Arrays PHP Sorting Arrays PHP Superglobals

## PHP Forms

PHP Form Handling PHP Form Validation PHP Form Required PHP Form URL/E-mail PHP Form Complete

## PHP Advanced

PHP Arrays Multi PHP Date PHP Include PHP File PHP File Upload PHP Cookies PHP Sessions PHP E-mail PHP Secure E-mail PHP Error PHP Exception PHP Filter

## PHP Database

PHP MySQL Intro PHP MySQL Connect PHP CREATE DB/Table PHP INSERT INTO PHP SELECT PHP WHERE PHP ORDER BY PHP UPDATE PHP DELETE PHP ODBC

## PHP XML

XML Expat Parser XML DOM XML SimpleXML

## PHP and AJAX

AJAX Intro AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX RSS Reader AJAX Poll

## PHP Reference

PHP Array PHP Calendar PHP Date PHP Directory PHP Error PHP Filesystem PHP Filter PHP FTP PHP HTTP PHP Libxml PHP Mail PHP Math PHP Misc PHP MySQLi PHP SimpleXML PHP String PHP XML PHP Zip PHP Timezones

## PHP Quiz

PHP Quiz PHP Certificate

# PHP 5 SimpleXML Functions

« Previous
Next Chapter »

## PHP SimpleXML Introduction

The SimpleXML extension provides is a simple way of getting an XML element's name and text, if you know the XML document's layout.

SimpleXML converts an XML document into a SimpleXMLElement object.

This object can then be processed, like any other object, with normal property selectors and array iterators.

Tip: Compared to DOM or the Expat parser, SimpleXML just takes a few lines of code to read text data from an element.

## Installation

The SimpleXML extension requires PHP 5.

As of PHP 5, the SimpleXML functions are part of the PHP core. No installation is required to use these functions.

## PHP 5 SimpleXML Functions

Function | Description
--- | ---
__construct() | Creates a new SimpleXMLElement object
addAttribute() | Adds an attribute to the SimpleXML element
addChild() | Adds a child element the SimpleXML element
asXML() | Formats the SimpleXML object's data in XML (version 1.0)
attributes() | Returns attributes and values within an XML tag
children() | Finds the children of a specified node
count() | Counts the children of a specified node
getDocNamespaces() | Returns the namespaces DECLARED in document
getName() | Returns the name of the XML tag referenced by the SimpleXML element
getNamespaces() | Returns the namespaces USED in document
registerXPathNamespace() | Creates a namespace context for the next XPath query
saveXML() | Alias of asXML()
simplexml_import_dom() | Returns a SimpleXMLElement object from a DOM node
simplexml_load_file() | Converts an XML file into a SimpleXMLElement object
simplexml_load_string() | Converts an XML string into a SimpleXMLElement object
xpath() | Runs an XPath query on XML data

## PHP 5 SimpleXML Iteration Functions

Function | Description
--- | ---
current() | Returns the current element
getChildren() | Returns the child elements of the current element
hasChildren() | Cheks whether the current element has children
key() | Return the current key
next() | Moves to the next element
rewind() | Rewind to the first element
valid() | Check whether the current element is valid

« Previous
Next Chapter »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE