10/10/2018, 00:12
Cách hiển thị hình ảnh trong HTML từ dữ liệu của XML
tôi có một file xml như sau:
<cars>
<car>
<name>Matiz (số tự động)</name>
<sale>15.500</sale>
<company>Daewoo</company>
<length>3.495</length>
<engine>796</engine>
<horsepower>52</horsepower>
<gearbox>4A</gearbox>
<capacity>5</capacity>
<brakeABS/>
<picture>../Image/Car/Daewoo/Martis.jpg</picture>
</car>
<car>
<name>Lanos SX </name>
<sale>17.600</sale>
<company>Daewoo</company>
<length>4.237</length>
<engine>1.498</engine>
<horsepower>94</horsepower>
<gearbox>5M</gearbox>
<capacity>5</capacity>
<brakeABS/>
<picture>../Image/Car/Daewoo/Lanos SX.jpg</picture>
</car>
<cars>
tôi muốn hiển thị nội dung của <picture> trong tag image của html . vậy tôi phải làm sao ? mong mọi người giúp đỡ
<cars>
<car>
<name>Matiz (số tự động)</name>
<sale>15.500</sale>
<company>Daewoo</company>
<length>3.495</length>
<engine>796</engine>
<horsepower>52</horsepower>
<gearbox>4A</gearbox>
<capacity>5</capacity>
<brakeABS/>
<picture>../Image/Car/Daewoo/Martis.jpg</picture>
</car>
<car>
<name>Lanos SX </name>
<sale>17.600</sale>
<company>Daewoo</company>
<length>4.237</length>
<engine>1.498</engine>
<horsepower>94</horsepower>
<gearbox>5M</gearbox>
<capacity>5</capacity>
<brakeABS/>
<picture>../Image/Car/Daewoo/Lanos SX.jpg</picture>
</car>
<cars>
tôi muốn hiển thị nội dung của <picture> trong tag image của html . vậy tôi phải làm sao ? mong mọi người giúp đỡ
Bài liên quan
[=========> Bổ sung bài viết <=========]
mà nếu dùng javascript thì phải dùng hàm for để đi hết các cây của xml, mà khi dùng hàm for(i=0,i<i.length,i++) thì báo lỗi white blank gì đó ngay chổ i<i.length không biết sửa thế nào! mong các bác giúp cho
<html>
<head>
<title>Enter the title of your HTML document here</title>
</head>
<body>
<script type="text/javascript">
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("gioithieuxe.xml")
x=xmlDoc.getElementsByTagName("car")
for(i=0;i<i.length;i++)
{
document.write(x.nodeName + ":")
document.write("(x[i].childNodes.nodeValues)<br/>")
}
</script>
</body>
</html>
nhưng bị lỗi này: "this is not well-formed , whitespace(blank, tab, cr, LF) expected và con trỏ chỉ vào hàm for(i=0;i<x.length;i++)
không hiểu là lổi gì, với lại tui muốn giá trị nodename là chử đậm thì phải làm sao, thank nhiều