Skip to content

Commit

Permalink
Add 'preserveWhiteSpace' boolean flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrnl authored Aug 18, 2016
1 parent bc1d004 commit eb69123
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/SimpleXMLReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class SimpleXMLReader extends XMLReader
* @var array
*/
protected $nodesCounter = array();

/**
* Do not remove redundant white space.
*
* @var bool
*/
public $preserveWhiteSpace = true;


/**
Expand Down Expand Up @@ -238,6 +245,7 @@ public function expandSimpleXml($version = "1.0", $encoding = "UTF-8", $classNam
{
$element = $this->expand();
$document = new DomDocument($version, $encoding);
$document->preserveWhiteSpace = $this->preserveWhiteSpace;
if ($element instanceof DOMCharacterData) {
$nodeName = array_splice($this->nodesParsed, -2, 1);
$nodeName = (isset($nodeName[0]) && $nodeName[0] ? $nodeName[0] : "root");
Expand All @@ -261,6 +269,7 @@ public function expandDomDocument($version = "1.0", $encoding = "UTF-8")
{
$element = $this->expand();
$document = new DomDocument($version, $encoding);
$document->preserveWhiteSpace = $this->preserveWhiteSpace;
if ($element instanceof DOMCharacterData) {
$nodeName = array_splice($this->nodesParsed, -2, 1);
$nodeName = (isset($nodeName[0]) && $nodeName[0] ? $nodeName[0] : "root");
Expand Down

0 comments on commit eb69123

Please sign in to comment.