我正在寻找一种方法从url
中的数据库中获取id行这是代码:
//Select the Database
mysql_select_db("vandermeulen",$db);
$result = mysql_query("select * from meul_rem_houses", $db);
//Create SimpleXMLElement object
$xml = new SimpleXMLElement('<funda-aanbod versie="1.0"/>');
//Add each column value a node of the XML object
while($row = mysql_fetch_assoc($result)) {
$mydata = $xml->addChild('wonen-object');
$mydata->addAttribute('ObjectID',$row['id']);
$mydata->addChild('kantoornaam',"Van der Meulen Makelaardij o.g.");
$mydata->addChild('aanbiedingstekst',$row['description']);
$mydata->addChild('aantal-kamers',$row['rooms']);
$mydata->addChild('postcode',$row['hzipcode']);
$mydata->addChild('huisnummer',$row['houseid']);
$mydata->addChild('straatnaam',$row['hlocation']);
$mydata->addChild('plaatsnaam',$row['hcity']);
$mydata->addChild('koophuur',$row['listing-type']);
$mydata->addChild('koopconditie',$row['listing-statur']);
$mydata->addChild('koopprijs',$row['price']);
$mydata->addChild('url',"http://vandermeu1.server154.nognietactief.nl/index.php?option=com_realestatemanager&task=view&id=.$row['id'].&catid=53&Itemid=299");
$mydata->addChild('bouwjaar',$row['year']);
$mydata->addChild('woonoppervlakte',$row['house_size']);
$mydata->addChild('soort-object',$row['property_type']);
}
mysql_close($db);
//Create the XML file
$fp = fopen("funda2.1.xml","wb");
//Write the XML nodes
fwrite($fp,$xml->asXML());
//Close the database connection
fclose($fp);
但它不在xml输出中
XML输出:
<koopprijs>127500</koopprijs>
<url/>
<bouwjaar>0</bouwjaar>
提前致谢
答案 0 :(得分:3)
更新
<?PHP
$url = htmlentities("http://vandermeu1.server154.nognietactief.nl/index.php?option=com_realestatemanager&task=view&id=".$row['uid']."&catid=53&Itemid=299");
$mydata->addChild('url',$url);
?>
答案 1 :(得分:0)
将$row['id']
更改为".$row['id']."
<强>编辑:强>
在这种情况下尝试使用CDATA:
$string = htmlspecialchars("<![CDATA[http://vandermeu1.server154.nognietactief.nl/index.php?option=com_realestatemanager&task=view&id=".$row['id']."&catid=53&Itemid=299]]>");
$mydata->addChild('url',$string)`
这是因为您的网址带有“&amp;”。我上次没有看到它。 您可以在此处阅读更多内容:http://www.w3schools.com/xml/xml_cdata.asp