1

The asp classic page I'm fixing connects to SQL Server 2008 to get data that is formatted as XML. Initially it was because the previous developer was using the IE specific XML data islands and I'm trying to make everything browser neutral.

Here's the asp code:

<xml id=xml_serial><%
if Program = "HNS" then
    set rs = conSQL.Execute( "T-SQL_stored_procedure_name" & CStr(OrderID) )
    while not RS.Eof
        Response.Write RS(0).Value
        RS.MoveNext
    wend
    RS.Close
end if
%></xml>

Here's how the HTML/XML looks after processed by the server:

<xml id=xml_serial>
    <file>
        <record>
            <serial>5265951</serial>
            <altserial>B10005265951AC</altserial>
            <price>$ 120.00</price>
            <serial1name>Serial #</serial1name>
            <serial2name>Serial</serial2name>
        </record>
    </file>
</xml>

I've used JQuery's xmlparser before but that was with a either an external file that could load the XML into a variable named xml that could be parsed with the parser.

The problem I'm having or don't understand is how to get the embedded xml into a variable for the JQuery parser to have something to parse? Is there some way to refer the id "xml_serial" that the parser can then point to and then parse the data?

I'm sure there is a way to do this, but I can't seem to find any examples that don't first point to an external xml file that is loaded into the xml variable prior to parsing.

Any help on this would be greatly appreciated. Thanks.

4

1 回答 1

0

如果您正在谈论使用http://api.jquery.com/jQuery.parseXML/上的 xml,您将在其中替换

var xml = "<rss version='2.0'><channel><title>RSS Title</title></channel></rss>",

var xml=<%=MyXML%>,

但首先您必须更改代码以构建 xml。

<%
MyXML=""
if Program = "HNS" then
    set rs = conSQL.Execute( "T-SQL_stored_procedure_name" & CStr(OrderID) )
    while not RS.Eof
        MyXML=MyXML& RS(0).Value  ' instead of response.write
        RS.MoveNext
    wend
    RS.Close
end if
%>
于 2013-02-17T03:38:24.023 回答