none
Reading HTML content in Javascript RRS feed

  • Question

  • Hi,
     
    I need to read a HTML content from a link using Javascript and then display the same on the page, probably in a DIV tag. I am plannig to use innertext property for displaying the content. Could anyone please provide me links on how a HTML content can be read (from another site link) and then be handled using Javascript. I am a newbie to web technologies so please pardon me if this is a stupid question!

    Update - I am looking for something like reading a RSS feed with HTML and Javascript code embedded in it!

    Thanks in advance.

    With regards,
    Software Engineer
    • Edited by Software Engineer Tuesday, September 9, 2008 11:39 AM Added more information
    • Moved by jack 321 Monday, September 15, 2008 3:34 AM off topic (Moved from JScript for the .NET Framework to Off-Topic Posts (Do Not Post Here))
    Tuesday, September 9, 2008 9:30 AM

All replies

  • I think it is important to understand that an RSS Feed is XML, not HTML. There are generally separate functions for the two. I am not sure about RSS Feeds, though. You should look for samples of reading RSS Feeds. In the context of JSCript .Net (this forum), look in the .Net for documentation of how to read XML documents.
    Sam Hobbs; see my SimpleSamples.Info
    • Proposed as answer by jack 321 Thursday, September 11, 2008 6:47 AM
    • Marked as answer by jack 321 Friday, September 12, 2008 6:44 AM
    • Unmarked as answer by Software Engineer Saturday, September 13, 2008 6:36 PM
    • Unproposed as answer by Software Engineer Saturday, September 13, 2008 7:53 PM
    Thursday, September 11, 2008 4:46 AM
  • Thanks Sam,

    With reference to your suggestion I did the following -
    ASPX file - 

    <%@ Page ContentType="text/html" Language="C#" AutoEventWireup="true" CodeBehind="HTMLLoadFromXML.aspx.cs" Inherits="InnerText.HTMLLoadFromXML" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html> 
    <head runat="server">  
    <title></title>  
    </head> 
    <body> 
        <script language="javascript" type="text/javascript">  
            function readHTML()  
            {  
                var readData = xmlDoc.getElementsByTagName('HyperData');  
                document.body.innerHTML = readData[0].childNodes[0].data;  
            }  
     
            function LoadTheData() {  
                if (window.ActiveXObject) {  
                    xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
                    xmlDoc.onreadystatechange = function() {  
                        if (xmlDoc.readyState == 4) readHTML()  
                    };  
                }  
                else {  
                    alert('Your browser can\'t handle this script');  
                    return;  
                }  
                xmlDoc.load("html.xml");          
        }  
        </script> 
     
        <form id="form1" action="DynamicLoad.aspx">  
        Specify the feed  
        <input id="Text1" type="text" value="http://localhost/html.xml" /><input 
            id="Button1" type="button" value="Load" onclick="javascript:LoadTheData();" /> 
        </form> 
    </body> 
    </html> 
     

    HTML.XML file -

    <emperors> 
        <HyperData> 
                <![CDATA[Header text
    <script language='javascript' type='text/javascript'>
    alert('Hey');
    </script>Footer text
                ]]> 
        </HyperData> 
    </emperors> 
     

    When I am loading the HTML content from the XML file into the main page, the Javascript included in the loaded part does not seem to be working while the static text is getting displayed just fine. Please suggest.

    Thanks in advance.

    With regards,

    Software Engineer
    Saturday, September 13, 2008 6:32 PM
  • Discussion in http://forums.asp.net/


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706
    Monday, September 15, 2008 3:34 AM