如何将 html 代码添加到 $newnode->setAttribute
How to add html code to $newnode->setAttribute
如何向 $newnode->setAttribute
添加一些 html 代码
这是我节点的代码
$newnode->setAttribute("name",$row2['sitename']);
现在我想要这样的东西
$newnode->setAttribute("name",<a href="link.php?id=$row2['id']">$row2['sitename']</a>);
感谢您提供任何帮助或指向我可以搜索解决方案的站点的链接
'name' 属性用于表单控件(例如输入元素),但看起来您想实际创建一个 link 元素。这是一个例子,其中 $doc 是您的文档对象:
$newNode = $doc->createElement("a",$row2['sitename']);
$newNode->setAttribute("href","link.php?id=".$row2['id']);
一旦附加到您的 DOM 树,元素的预期输出将类似于:
<a href="link.php?id=123">yoursitename</a>
感谢大家的帮助。
我现在有了解决方案,这里就完成了
xml.php
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name",$row2['sitename']);
$newnode->setAttribute("address", $row['formatted_adress']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['longi']);
$newnode->setAttribute("id", $row2['id']);
}
javascript google 地图代码
downloadUrl("xml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var site_id = markers[i].getAttribute("id");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = "<b>" + name + "</b> <br/>" + address + " <br/> <a href='index.php?id=" + site_id +"'>more...</a><br />";
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
如何向 $newnode->setAttribute
添加一些 html 代码这是我节点的代码
$newnode->setAttribute("name",$row2['sitename']);
现在我想要这样的东西
$newnode->setAttribute("name",<a href="link.php?id=$row2['id']">$row2['sitename']</a>);
感谢您提供任何帮助或指向我可以搜索解决方案的站点的链接
'name' 属性用于表单控件(例如输入元素),但看起来您想实际创建一个 link 元素。这是一个例子,其中 $doc 是您的文档对象:
$newNode = $doc->createElement("a",$row2['sitename']);
$newNode->setAttribute("href","link.php?id=".$row2['id']);
一旦附加到您的 DOM 树,元素的预期输出将类似于:
<a href="link.php?id=123">yoursitename</a>
感谢大家的帮助。
我现在有了解决方案,这里就完成了
xml.php
// ADD TO XML DOCUMENT NODE
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("name",$row2['sitename']);
$newnode->setAttribute("address", $row['formatted_adress']);
$newnode->setAttribute("lat", $row['lat']);
$newnode->setAttribute("lng", $row['longi']);
$newnode->setAttribute("id", $row2['id']);
}
javascript google 地图代码
downloadUrl("xml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var site_id = markers[i].getAttribute("id");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = "<b>" + name + "</b> <br/>" + address + " <br/> <a href='index.php?id=" + site_id +"'>more...</a><br />";
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}