


Detailed explanation of examples on page 1/2 of obtaining values and data modification through javascript xml xsl
1.example.xml--Main data file
<?xml version="1.0" encoding="UTF-8"?> <?xml:stylesheet type="text/xsl" href="example.xsl"?> <projects id="1"> <project title="一级标题1" index="1"> <items isTrunk="false" title="二级标题1.1" id="items_1"> <result type="2">1</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> <remark></remark> </items> <items isTrunk="false" title="二级标题1.2" id="items_2"> <result type="2">3</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </items> </project> <project title="一级标题2" index="2"> <items isTrunk="false" title="二级标题2.1" id="items_3"> <result type="3">3</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </items> <items isTrunk="true" title="二级标题2.2"> <item title="三级标题2.2.1" id="item_1"> <result type="1">2</result> <officer><![CDATA[居然是乱码]]></officer> <classified>1</classified> <eligibility>0</eligibility> </item> <item title="三级标题2.2.2" id="item_2"> <result type="1">3</result> <officer><![CDATA[<><>]]></officer> <classified>1</classified> <eligibility>0</eligibility> </item> </items> <items isTrunk="true" title="二级标题2.3"> <item title="三级标题2.3.1" id="item_3"> <result type="2">1</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </item> <item title="三级标题2.3.2" id="item_4"> <result type="2">1</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </item> </items> </project> <project title="一级标题3" index="3"> <items isTrunk="false" title="二级标题3.1" id="items_4"> <result type="4" units="元">25345</result> <officer><![CDATA[sinoly]]></officer> <classified>1</classified> <eligibility>0</eligibility> </items> <items isTrunk="false" title="二级标题3.2" id="items_5"> <result type="4" units="元">9865764</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </items> <items isTrunk="false" title="二级标题3.3" id="items_6"> <result type="2">0</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </items> <items isTrunk="true" title="二级标题3.4"> <item title="三级标题3.4.1" id="item_5"> <result type="1">0</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </item> <item title="三级标题3.4.2" id="item_6"> <result type="1">0</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </item> <item title="三级标题3.4.3" id="item_7"> <result type="1">0</result> <officer><![CDATA[]]></officer> <classified>1</classified> <eligibility>0</eligibility> </item> </items> </project> </projects>
2.example.xsl--Style file, it is very convenient to get xml data
<?xml version="1.0" encoding="gb2312"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!--根模板--> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:apply-templates select="projects/project"/> <h6> <button type="submit" class="btn1_mouseout" onmouseover="this.className='btn1_mouseover'" onmouseout="this.className='btn1_mouseout'" title="提交"> 下一步</button> </h6> </xsl:template> <!--主题模板--> <xsl:template match="project"> <TABLE border="0" cellspacing="0" cellpadding="0" class="table"> <tr> <td colspan="5" align="center" class="tright"> <h2> <xsl:number value="position()" format="一、"/><xsl:value-of select="@title"/> </h2> </td> </tr> <xsl:apply-templates select="items"/> </TABLE> <BR/> </xsl:template> <!--一级题干模板--> <xsl:template match="items"> <tr> <td colspan="2" class="tright"> <xsl:number value="position()" format="1."/><xsl:value-of select="@title"/> </td> <xsl:choose> <xsl:when test="@isTrunk[.='false']"> <xsl:apply-templates select="result"/> <xsl:apply-templates select="officer"/> </xsl:when> <xsl:otherwise> <td colspan="3" class="tright" style="color:blue;font-weight:bolder"> 注意以下几点 </td> <xsl:apply-templates select="item"/> </xsl:otherwise> </xsl:choose> </tr> </xsl:template> <!--二级题干模板--> <xsl:template match="item"> <tr> <td class="tright" style="padding-left:20px" colspan="2"> <h4><xsl:number value="position()" format="(a)."/><xsl:value-of select="@title"/></h4> </td> <xsl:apply-templates select="result"/> <xsl:apply-templates select="officer"/> </tr> </xsl:template> <!--选择框模板--> <xsl:template match="result"> <xsl:choose> <xsl:when test="@type = '1'"> <td width="15%"> <xsl:element name="select"> <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute> <!--<select name="select">--> <xsl:choose> <xsl:when test=".='0'"> <option value="0" selected="selected">请选择 </option> <option value="1">符合</option> <option value="2">基本符合</option> <option value="3">不符合</option> </xsl:when> <xsl:when test=".='1'"> <option value="0">请选择 </option> <option value="1" selected="selected">符合</option> <option value="2">基本符合</option> <option value="3">不符合</option> </xsl:when> <xsl:when test=".='2'"> <option value="0">请选择 </option> <option value="1">符合</option> <option value="2" selected="selected">基本符合</option> <option value="3">不符合</option> </xsl:when> <xsl:when test=".='3'"> <option value="0">请选择 </option> <option value="1">符合</option> <option value="2">基本符合</option> <option value="3" selected="selected">不符合</option> </xsl:when> </xsl:choose> <!--</select>--> </xsl:element> </td> </xsl:when> <xsl:when test="@type = '2'"> <td width="15%"> <xsl:element name="select"> <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute> <xsl:choose> <xsl:when test=".='0'"> <option value="0" selected="selected">请选择 </option> <option value="1">是</option> <option value="2">否</option> </xsl:when> <xsl:when test=".='1'"> <option value="0">请选择 </option> <option value="1" selected="selected">是</option> <option value="2">否</option> </xsl:when> <xsl:when test=".='3'"> <option value="0">请选择 </option> <option value="1">是</option> <option value="2" selected="selected">否</option> </xsl:when> </xsl:choose> </xsl:element> </td> </xsl:when> <xsl:when test="@type = '3'"> <td width="15%"> <xsl:element name="select"> <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute> <xsl:choose> <xsl:when test=".='0'"> <option value="0" selected="selected">请选择 </option> <option value="1">有</option> <option value="2">无</option> </xsl:when> <xsl:when test=".='1'"> <option value="0">请选择 </option> <option value="1" selected="selected">有</option> <option value="2">无</option> </xsl:when> <xsl:when test=".='3'"> <option value="0">请选择 </option> <option value="1">有</option> <option value="2" selected="selected">无</option> </xsl:when> </xsl:choose> </xsl:element> </td> </xsl:when> <xsl:otherwise> <td width="15%"> <xsl:element name="textarea"> <xsl:attribute name="name">re_<xsl:value-of select="../@id"/></xsl:attribute><xsl:value-of select="."/> </xsl:element> <xsl:value-of select="@units"/> </td> </xsl:otherwise> </xsl:choose> </xsl:template> <!--责任人模板--> <xsl:template match="officer"> <td width="9%" class="tright">责任人</td> <td width="11%"> <xsl:element name="textarea"> <xsl:attribute name="name">of_<xsl:value-of select="../@id"/></xsl:attribute> <xsl:value-of select="."/> </xsl:element> </td> </xsl:template> </xsl:stylesheet>
Current 1/2 page 12Read the full text on the next page
The above is the detailed content of Detailed explanation of examples on page 1/2 of obtaining values and data modification through javascript xml xsl. 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

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

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Use PHPXML functions to process XML data: Parse XML data: simplexml_load_file() and simplexml_load_string() load XML files or strings. Access XML data: Use the properties and methods of the SimpleXML object to obtain element names, attribute values, and subelements. Modify XML data: add new elements and attributes using the addChild() and addAttribute() methods. Serialized XML data: The asXML() method converts a SimpleXML object into an XML string. Practical example: parse product feed XML, extract product information, transform and store it into a database.

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service
