Trying to generate XML file from returend SQL query results.
The SQL query returns ItemId
, ItemName
, ItemDescription
from Items
table.
I want to list the ItemName
s inside XML like so:
XML
...
<item>
<name>ItemName1</name>
</item>
<item>
<name>ItemName2</name>
</item>
...
PHP
...
while($items = @mysql_fetch_assoc($query)){
foreach($items as $row){
}
$node = $doc->createElement( item );
$node = $root->appendChild($node);
$child = $doc->createElement( name );
$child = $node->appendChild($child);
$value = $doc->createTextNode($row[ ItemName ]); // !
$value = $child->appendChild($value);
}}
...
My XML structure generates properly but the problem is I get the first letter of each of the item s ItemDescription
, instead ItemName
inside every name
element like so:
...
<name>D</name>
...
<name>H</name>
...
头两个项目有说明,从D和H信函开始。
What is causing this behaviour?