S
S
stanlee2016-05-29 03:11:30
PHP
stanlee, 2016-05-29 03:11:30

Strange xml behavior?

Generate xml using DOM

<Massage>
<Order>
<orderID>416267</orderID>
....

after some time xml is pouring
What could it be?
<Massage>0ۺQ<Order&g

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
stanlee, 2016-05-29
@stanlee

mini slassic

class Xml extends \DOMImplementation
{
  public function __construct()
  {
    $this->dom = $this->createDocument();
    $this->dom->encoding = 'utf-8';
    $this->dom->formatOutput = true;
    $this->dom->preserveWhiteSpace = false;
  }


  function addElement($node, $name, $text = '')
  {
    $element = $this->dom->createElement($name, $text);
    $node->appendChild($element);

    return $element;
  }


  public function getDocument()
  {
    return $this->dom->saveXML();
  }
}

and a piece from the generation
$this->xml = new Xml();
$xmlMassage = $this->xml->addElement($this->xml->dom, 'Massage');

$xmlOrder = $this->xml->addElement($xmlMassage, 'Order');
$this->xml->addElement($xmlOrder, 'orderID', 416267);
...
return $this->xml->getDocument();

nothing so supernatural
on the other machine is not manifested

X
xmoonlight, 2016-05-29
@xmoonlight

are the server page encoding versions by default on this and that machine exactly the same?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question