I am trying to display xml in browser.i have created a xml like
$query2 = "SELECT * FROM user where user_id = 7";
$dbresult = mysqli_query($dbcon,$query2) or die('query error...');
$doc = new DomDocument('1.0');
$doc->formatOutput = true;
$root = $doc->createElement('root');
$root = $doc->appendChild($root);
while($row = mysqli_fetch_array($dbresult)) {
$userId = $doc->createElement('UserId');
$userId = $root->appendChild($userId);
$value = $doc->createTextNode($row[0]);
$value = $userId->appendChild($value);
$psw = $doc->createElement('Password');
$psw = $root->appendChild($psw);
$value = $doc->createTextNode($row[2]);
$value = $psw->appendChild($value);
}
echo $doc->saveXML();
$doc->save("test.xml");
it displaying just data like
7 pwd123
but i want data like
<xml>
<root>
<userId>7</userId>
<password>pwd123</password>
</root>
</xml>
what to do for that? thanks