


Sample code sharing for hyperlink processing when binding xml data island
When writing a map space search, the data results returned by ajax need to be listed in a traditional table in addition to punctuation on the map, and the information can be viewed by clicking, because the processing of the returned results needs to be flexible enough. , so the format cannot be hard-coded in js. The XML data island method is used here (the system only needs to consider IE) and only the XML data information to be used is returned. The specific layout on the HTML page can be customized by other developers.
The following code removes the ajax part, and simply demonstrates how to generate an xml data island, how to bind it to an html table, and display related link information. The href content of the link can be saved in xml data and processed with the datafld attribute.
<html xmlns=""> <head> <title>XML数据岛</title> </head> <script type="text/jscript">... //获取xml,实际应用中大多是ajax异步获取的 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; } //简单的添加xml信息 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();">获取数据 </button> <button onclick="javascript:addData();">添加数据 </button> <div id="xmlDataPanel"> </div> <div style="overflow: scroll; height: 180;width:180" align="center"> <div align="left"> <!--绑定,超链接的地方用 datafld属性,href的值也可以保存在 xml数据岛当中,比较灵活,可以使js函数或者一个url地址--> <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> </html>
The above is the detailed content of Sample code sharing for hyperlink processing when binding xml data island. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to solve the problem that hyperlinks cannot be opened. With the rapid development of the Internet, hyperlinks have become an indispensable part of our daily lives. We often see and use hyperlinks on various platforms such as web pages, emails, and social media. However, sometimes we may encounter problems with hyperlinks not opening, which makes us confused and frustrated. In this article, we will discuss the reasons why hyperlinks cannot be opened and their solutions, hoping to help you solve this problem. First, let us understand the possible reasons why hyperlinks cannot be opened. The following are some common

Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

Implementing filtering and sorting of XML data using Python Introduction: XML is a commonly used data exchange format that stores data in the form of tags and attributes. When processing XML data, we often need to filter and sort the data. Python provides many useful tools and libraries to process XML data. This article will introduce how to use Python to filter and sort XML data. Reading the XML file Before we begin, we need to read the XML file. Python has many XML processing libraries,

When many of our friends use WPS to edit content, they sometimes add hyperlinks to specific text. Recently, some friends have reported that WPS hyperlinks cannot be opened and cannot be clicked to access after using many methods. About this How to solve the problem? In this software tutorial, the editor will share the specific solutions, hoping to help the majority of users. Solution to WPS hyperlink not opening: Method 1: Move the mouse over the hyperlink to see if it becomes clickable. 1. Open the software, click "File" in the upper left corner of the page, and select "Options" in the menu below. 2. After entering the new interface, click "Edit&rdq" on the left

In recent years, with the continuous development of network technology, our lives are inseparable from various digital tools and the Internet. When processing documents, especially in writing, we often use word documents. However, sometimes we may encounter a difficult problem, that is, the hyperlink in the word document cannot be opened. This issue will be discussed below. First of all, we need to make it clear that hyperlinks refer to links added in word documents to other documents, web pages, directories, bookmarks, etc. When we click on these links, I

Python implements conversion between XML and JSON Introduction: In the daily development process, we often need to convert data between different formats. XML and JSON are common data exchange formats. In Python, we can use various libraries to convert between XML and JSON. This article will introduce several commonly used methods, with code examples. 1. To convert XML to JSON in Python, we can use the xml.etree.ElementTree module

Handling Errors and Exceptions in XML Using Python XML is a commonly used data format used to store and represent structured data. When we use Python to process XML, sometimes we may encounter some errors and exceptions. In this article, I will introduce how to use Python to handle errors and exceptions in XML, and provide some sample code for reference. Use try-except statement to catch XML parsing errors When we use Python to parse XML, sometimes we may encounter some
