2 개의 파일 xml과 xsl이 있습니다. xslt를 사용하여 xml 데이터를 가져 와서 html 테이블로 변환하고 싶습니다. 아래의 코드는 Chrome에서 작동하지 않으며 왜 xslt를 적절하게 사용하는 방법에 대한 조언이나 xslt 대신 사용할 수있는 방법에 대한 조언이 확실하지 않습니다.xslt는 xml을 html로 변환합니다.
test.xml의
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
</catalog>`
style.xsl
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title" /></td>
<td><xsl:value-of select="artist" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>`
Bummer ... XSLT를 사용하지 않고 동일한 작업을 수행하는 방법에 대한 권장 사항은 무엇입니까? –
필자는 필적 할만한 도구를 찾지 못할 것이라고 생각합니다. 스타일 시트 제공을 시도해보십시오. 또는 여기에 설명 된대로 브라우저를 설정하십시오. http://stackoverflow.com/q/18586921/3016153 –
쿨 ... 고마워! –