0% found this document useful (0 votes)
8 views1 page

Split 2860710731016212515

Forth pdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Split 2860710731016212515

Forth pdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SimpleXML :

• SimpleXML is an extension that allows us to easily manipulate and get XMLdata.


• The SimpleXML extension is the tool of choice for parsing an XMLdocument.
• SimpleXML turns an XML document into a data structure you can iterate through likea
collection of arrays andobjects.
• The SimpleXML extension includes interoperability with the DOM for writing XML filesand
built-in XPathsupport.
• SimpleXML is easier to code than the DOM, as its nameimplies.
SimpleXMLElement class represents an element in an XML document.
• To create root element of xml document, first create object of SimpleXMLElement class and
initialize with rootelement.
• For example :
• $bk=newSimpleXMLElement(“<bookstore/>”);

Methods or functions of simpleXMLElement class

Function name description syntax example

addChild() The addChild() addChild(name,val $book = $bk->addchild(“book”);


function adds a ue);
child element to
the SimpleXML
elemen
addAttribute() adds an attribute addAttribute(name, $book->addAttribute(“Category” ,
to the value); “Technical”);
SimpleXML
element.
getName() Returns the name getName(); $bk->getName();
of the XML tag
referenced by the
SimpleXML
element
asXML() Returns a well- asXML([filename])
formed XML string ; echo $bk->asXML();
(XML version 1.0)
from a SimpleXML
object
children() Returns the children() foreach ($book->children() as $child)
children of a {
specified node as echo "Child node: " . $child .
an array "<br>";
}
attributes(); Returns the attributes(); foreach ($book->attributes () as
attributes/values $k=>$v)
of an element {
echo $k : $v . "<br>";
}
count(); The count() count(); $cnt=$book->count();
function counts
the children of a
specified node.

17

You might also like