Hyperlink processing for XML data island binding

Source: Internet
Author: User
Tags html page

In the map space search, the results of the data returned with Ajax, in addition to the punctuation on the map need to be listed in the traditional form, and can click to view information, because the need for the return of the results of the processing is flexible enough, so can not write dead in JS format. Here the way to use the XML data island (the system is only to consider IE) only to use the XML data information returned, how to layout on the HTML page can be customized by other developers themselves.

The following code removes the Ajax section and simply demonstrates how to generate an XML data island and how to bind to HTML tables and display related link information. The href content of the link can be saved in the XML data and processed with the datafld attribute.

<title>xml Data Island </title>

<script type= "Text/jscript" ....
Get XML, most of the actual applications are AJAX-acquired asynchronously
function GetData ()
... {
var xmldata= "<xml id=" XmlData "><root>";
for (Var i=0;i<5;i++)
... {
Try
... {
var id= "Name" +i;
var type= "Type" +i;
xmldata+= "<METADATA><Name>" +id+ "</Name>;<type>" +type+ "</Type><Href> Javascript:aler t (' "+id+") </Href></METADATA> ";
pointindex++;
}
catch (E)
... {

}
}
xmldata+= "</root></xml>";
Document.all.xmldatapanel.innerhtml=xmldata;
}
Simple Add XML information
function AddData ()
... {
var xmldata= document.all.xmlDataPanel.innerHTML;
Xmldata=xmldata.replace ("</root></xml>", "");
xmldata+= "<metadata><name>newname</name><type >newType</Type><Href> Javascript:alert (' newName ') </Href></METADATA>;
xmldata+= "</root></xml>";
Document.all.xmldatapanel.innerhtml=xmldata;
}
</script>

<body>
<button onclick= "Javascript:getdata ();" > Get Data </button>
<button onclick= "Javascript:adddata ();" > Add Data </button>
<div id= "Xmldatapanel" >
</div>
<div style= "Overflow:scroll; height:180;width:180 "align=" Center ">
<div align= "Left" >
<!--bindings, hyperlinks where the datafld attribute, the value of href can also be saved in the XML data island, more flexible, you can make a JS function or a URL address-->
<table datasrc= "#xmlData" border= "1" >
<tr>
<td>
<a datafld= "Href" ><span datafld= "Name" ></span></a>
</td>
<td>
<span datafld= "Type" ></span>
</td>
</tr>
</table>
</div>
</div>

</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.