JS and ASP for remote XML reading

Source: Internet
Author: User

JavaScript to read remote XML
<Script language = "JavaScript">
VaR xmldoc = new activexobject ("Microsoft. xmldom ");
Xmldoc. async = false;
Xmldoc. Load ("http://www.donews.com/rss.xml ");
// Xmldoc. loadxml ("<description> character </description> ");

VaR root=xmldoc.doc umentelement;
VaR number = root. selectnodes ("channel/item"). length;

If (number <= 10)
Alert ("sorry, the number of news lines is already less than the number of news lines to be displayed! ");
Else
{
Document. writeln ("<p align = 'center' class = 'font'>" + root. childnodes (0 ). childnodes (0 ). text + "<p> ");
Document. writeln ("<P class = 'indent '>" + root. childnodes (0). childnodes (1). Text + "</P> ");
Document. writeln ("<P class = 'indent '>" + root. childnodes (0). childnodes (2). Text + "</P> ");
For (VAR I = 0; I <10; I ++)
{
Document. writeln ("<B>" + root. childnodes (0 ). childnodes (5 + I ). childnodes (0 ). text + "</B> <br/> ");
Document. writeln ("<small>" + root. childnodes (0 ). childnodes (5 + I ). childnodes (4 ). text + "& nbsp;" + root. childnodes (0 ). childnodes (5 + I ). childnodes (3 ). text + "</small> <br/> ");
Document. writeln ("<small> <a href = '" + root. childnodes (0 ). childnodes (5 + I ). childnodes (1 ). text + "'>" + root. childnodes (0 ). childnodes (5 + I ). childnodes (1 ). text + "</a> </small> <br/> ");
Document. writeln ("<P class = 'indent '>" + root. selectnodes ("channel/item/description") (I ). text + "</P> <br/> ");
}
}
</SCRIPT>

Implement ASP to read remote XML files
<%
Dim xmldoc
Dim Root
Dim number

Set HTTP = server. Createobject ("Microsoft. XMLHTTP ")
HTTP. Open "get", "http://www.donews.com/rss.xml", false
HTTP. Send

Set xmldoc = server. Createobject ("Microsoft. xmldom ")
Xmldoc. async = false
Xmldoc. validateonparse = false
Xmldoc. Load (HTTP. responsexml)

Set root=xmldoc.doc umentelement
Number = root. selectnodes ("channel/item"). Length

If number <= 10 then
%>
<Script language = "vbscept">
Msgbox "sorry, the number of news lines is already less than the number of news lines to be displayed! "
</SCRIPT>
<%
Else
Response. Write "<p align = 'center' class = 'font'>" & root. childnodes (0). childnodes (0). Text & "<p>"
Response. Write "<P class = 'indent '>" & root. childnodes (0). childnodes (1). Text & "</P>"
Response. Write "<P class = 'indent '>" & root. childnodes (0). childnodes (2). Text & "</P>"
For I = 0 to 9
Response. write "<B>" & root. childnodes (0 ). childnodes (5 + I ). childnodes (0 ). text & "</B> <br/>"
Response. write "<small>" & root. childnodes (0 ). childnodes (5 + I ). childnodes (4 ). text & root. childnodes (0 ). childnodes (5 + I ). childnodes (3 ). text & "</small> <br/>"
Response. write "<small> <a href = '" & root. childnodes (0 ). childnodes (5 + I ). childnodes (1 ). text & "'>" & root. childnodes (0 ). childnodes (5 + I ). childnodes (1 ). text & "</a> </small> <br/>"
Response. write "<P class = 'indent '>" & root. selectnodes ("channel/item/description") (I ). text & "</P> <br/>"
Next
End if
%>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.