XML containing link throws error in Visual Studio

2019-07-31 03:10发布

I'm an XSLT noob, so my apologies if there is an obvious answer to the following question. I'm working on a stylesheet. The xml to which I'd like to apply it contains links. These throw errors in the VS XML debugger and seem to keep the XML transform from happening correctly in browsers. Can someone please tell me what I'm doing wrong?

Here is the XML:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Some title</title>
    <description>a link should be here</description>
  </channel>
</rss>

When I replace "a link should be here" with a URL, I see the issue.

For XSLT content, anything gets the point across, such as the following from the w3schools site:

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
  <body>
    <h2>My CD Collection</h2>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th>Title</th>
        <th>Artist</th>
      </tr>
      <tr>
        <td>.</td>
        <td>.</td>
      </tr>
    </table>
  </body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks in advance for any help.

2条回答
Root(大扎)
2楼-- · 2019-07-31 03:17

XML is tricky.

Make sure all brackets are closed, also make sure your special characters in the URL such as & it converted into &amp;

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-07-31 03:20

I've seen xml get tricked up with URLs that have "&" in them. XML wants it to be & followed by amp; and not just &. Strict parsers will crap out when trying to parse it.

Example:

&

would be replaced with

&amp;
查看更多
登录 后发表回答