locked
XML control has runtime error: syntax error, unrecognized expression RRS feed

  • Question

  • User132483923 posted

    Why am I getting this error if the web form otherwise works properly?

    I inserted an Xml control into a web form. The Xml document source is an XML file, with the structure below. The transform source is the XSLT file below.  The XSLT file should use the data in the XML file to create a list of hyperlinks.  This works when I test it - the hyperlink shows up and has the correct URL when I hover over it.  The rest of the web form also loads properly. But, I get this error:

    JavaScript runtime error: Syntax error, unrecognized expression: ?xml

    I created an Xml control in the page source:

    <asp:Xml ID="periodicalList" runat="server" DocumentSource="~/App_Data/periodicals.xml" TransformSource="~/stylesheet/periodicalDDL.xslt"></asp:Xml>

    The xml file:

    <periodicals>

      <periodical name="test" pre="0" type="journal" id="000001" />

    </periodicals>

    The xslt file:

    <?xml version="1.0" encoding="utf-8"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

      <xsl:template match="/">

        <div>

           <xsl:for-each select="periodicals/periodical">

              <xsl:element name="a">

                <xsl:attribute name="href">

                  <xsl:text>/db/</xsl:text>

                  <xsl:value-of select="@type" disable-output-escaping="yes"/>

                  <xsl:text>.aspx?id=</xsl:text>

                  <xsl:value-of select="@id" disable-output-escaping="yes"/>

                </xsl:attribute>

                <xsl:attribute name="target">

                  <xsl:text>_blank</xsl:text>

                </xsl:attribute>

                <xsl:value-of select="@name" disable-output-escaping="yes"/>

              </xsl:element>

              <br />

          </xsl:for-each>

        </div>

      </xsl:template>

    </xsl:stylesheet>

    Sunday, April 26, 2015 11:54 PM

Answers

  • User132483923 posted

    This is apparently a known bug in VS 2013.  I inserted the following into the web.config file and the error no longer occurs. I'm not sure what problem this fixes or how it fixes it, but so far it has worked.

    <appSettings>
     
    <add key="vs:EnableBrowserLink" value="false" />
    </appSettings>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 29, 2015 5:33 PM

All replies

  • User132483923 posted

    I tried adding the Xml control in the .cs code-behind, rather than in the .aspx.  Same problem.

    if (Page.IsPostBack == false)

            {    Xml loadPubs = new Xml();

                loadPubs.DocumentSource = Server.MapPath("~/App_Data/periodicals.xml");

                loadPubs.TransformSource = Server.MapPath("~/stylesheet/periodicalDDL.xslt");

                right.Controls.Add(loadPubs);

            }

    Monday, April 27, 2015 12:57 PM
  • User1711366110 posted

    I tried adding the Xml control in the .cs code-behind, rather than in the .aspx.  Same problem.

      As per this case, the following links which may guide you to resolve this issue :

    1. Click here to get the sample code with step by step process about Creating a Web Page to Display XML Data

    2. Click here to get the sample code with step by step process about Transforming XML with XSLT and ASP.NET

    --
    with regards,
    Edwin

    Tuesday, April 28, 2015 3:47 AM
  • User132483923 posted

    This is apparently a known bug in VS 2013.  I inserted the following into the web.config file and the error no longer occurs. I'm not sure what problem this fixes or how it fixes it, but so far it has worked.

    <appSettings>
     
    <add key="vs:EnableBrowserLink" value="false" />
    </appSettings>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 29, 2015 5:33 PM