Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sample Analysis of data binding in XML

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you the "sample analysis of data binding in XML", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "sample analysis of data binding in XML".

HTML not only contains a large number of formatting statements, but also full of content data everywhere, which makes people look really big. Artists may inadvertently modify the content data when adjusting the interface layout; industry content maintenance personnel often unintentionally mess up the industry layout code when maintaining the data.

As a result, people began to consciously avoid this chaotic situation. Using XML for data description, only the page layout code is retained in HTML, so that the data is separated in the interface, and the content data is no longer lost because of changing the layout; nor will the page layout be changed when maintaining the data.

The data and the interface have been separated, and it seems that we need some means to combine them organically. XML data with different HTML can give customers different ways to browse data. XML data island can naturally introduce data from XML into HTML without having to write tedious code.

Next, I would like to illustrate to you with examples.

Suppose we have a XML file called "Book.xml" to store book information, as follows.

Romance of the three Kingdoms Luo Guanzhong Literature and Art Publishing House Cao Xueqin Sanqin Publishing House (Volume 1 and 2) Wu Chengen people's Literature Publishing House

Each book node (Book) has four attributes: classification, data, margin, discount, and five sub-elements: title, author, publisher, book number and price. This is just to show you how to use the XML data island, so the definition of the data structure is very simple, and the amount of data is not very large.

We want to display the contents of the XML in HTML as a table. Let's start writing HTML files now. The first step is to construct a table in HTML to display the information about the book. I'm not going to elaborate on this part. We will focus on how to define the XML data guide and how to bind the HTML table to the datasheet.

XML data island, as its name implies, acts as a data source by introducing a XML file that stores data and assigning an ID to it for easy reference in HTML. The definition code is as follows:

In general, we will write this code in the tag. ID is its identifier and can be easily referenced elsewhere in the HTML file. Src is the location of the XML data file, which can be a relative location or a valid URL. In this case, the value is "Test07.xml", indicating that this is a file named "Test07.xml" that is stored in the same location as the HTML file.

Book title category book number author publishing house pricing quantity margin

You can see that in the tag, we have added datasrc= "# XMLData" to indicate that the data in the table comes from a data island called "XMLData". In particular, we must use "#" plus the data island ID when referencing the data guide.

At the same time, you need to place a tag in each cell tag and specify a field, for example, to indicate that the tag is bound to the title field, and the field value is automatically populated into the tag.

The above is all the content of the article "sample Analysis of data binding in XML". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report