0

I have to insert a XML string into specific node.

$domtree = new DOMDocument('1.0', 'UTF-8');

/* create the root element of the xml tree */
$xmlRoot = $domtree->createElement("Project");


/* append it to the document created */
$xmlRoot = $domtree->appendChild($xmlRoot);
$projectInfo=createProjectInfo();//this will return xml string <ProjectInfo>Some text here</ProjectInfo>

$xmlRoot->loadXML($projectInfo);//here i am getting  "Fatal error: Call to undefined method DOMElement::loadXML() in."

Here is what I want:

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <ProjectInfo>Some text here</ProjectInfo>
</Project>

It's different than what the others suggested; here, I am dealing with the string xml not xtml.

shim
  • 9,289
  • 12
  • 69
  • 108
Kaleem Nalband
  • 687
  • 7
  • 21

0 Answers0