Skip to content

A simple extended version of SimpleXMLElement that adds CDATA whenever necessary

License

Notifications You must be signed in to change notification settings

redelschaap/SimpleXMLElementExtended

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

SimpleXMLElementExtended

A simple extended version of SimpleXMLElement that adds CDATA whenever necessary.

##Example When using SimpleXMLElementExtended, you just call the same addChild() method like you're used to when using SimpleXMLElement. For example, the following code...

$xml = new SimpleXMLElementExtended( '<xmlData></xmlData>' );

$child = $xml->addChild( 'data' );

$child->addChild( 'child1' );
$child->addChild( 'child2', 'value' );
$child->addChild( 'child3', 'A string with <a href="/test?p=1&q=e">HTML elements</a>.' )
		->addAttribute( 'attribute', 'value' );

$subChild = $child->addChild( 'child4' );
$subChild->addChild( 'child4_1', 'value' );

print $xml->asXML();

...outputs the following XML:

<?xml version="1.0"?>
<xmlData>
	<data>
		<child1/>
		<child2>value</child2>
		<child3 attribute="value"><![CDATA[A string with <a href="/test?p=1&q=e">HTML elements</a>.]]></child3>
		<child4>
			<child4_1>value</child4_1>    
		</child4>
	</data>
</xmlData>

About

A simple extended version of SimpleXMLElement that adds CDATA whenever necessary

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages