rthcupid
rthcupid

Reputation: 61

ZF2 XML Creation

I am new to zend framework 2 . Can any one describe me how to create XML files using ZF2 . I need to access remote server via sending data through XML file . So I need to create a xml file with lot of sub divisions by creating and appending XML file . Please somebody describe me how to do it . Thanks in advance .

Upvotes: 0

Views: 254

Answers (2)

rthcupid
rthcupid

Reputation: 61

 $b = $doc->createElement("Auth");
$partnerName = $doc->createElement("partnerName");
$partnerName->appendChild(
  $doc->createTextNode('Partnername')
);
$b->appendChild($partnerName);

$name = $doc->createElement("name");
$name->appendChild(
  $doc->createTextNode('username')
);

use this we can create xml file and use $xml = $doc->saveXML(); to return the xml file

Upvotes: 2

Remesh
Remesh

Reputation: 36

Please use php xml functions

$doc = new \DOMDocument('1.0', 'UTF-8');
$elm = $doc->createElement("NCScript");
$elm->setAttribute('xmlns', 'http://yourpath:NStd');
$elm->setAttribute('xmlns:NStd', 'http://yourpath');
$elm->setAttribute('xmlns:xsi', 'http://yourpath');
$doc->appendChild($elm);

Upvotes: 2

Related Questions