Help me with xmlfile please

Hi there,

I’m new to asp.net and got stuck on page 124-126(Build ur own asp.net web site…). I just cannot link the Ads.xml to the AdRotator file. Any help will be well appreciated. Thank you. :confused:

What are you having a problem with? What error are you getting?

The AdRotator page cannot find the Ads.xml file. Both pages were created separately but my thought is that they should be able to link to create one output page.

Thanks for responding.

Can you post the code you are using to call the Ads.xml file? What folders are each of the files in? How are you calling the page?

<?xml version=“1.0” encoding=“utf-8” ?>
<Advertisements>
<Ad>
<ImageUrl>workatdorknozzle.gif</ImageUrl>
<NavigateUrl>http://www.example.com</NavigateUrl>
<TargetUrl>_blank</TargetUrl>
<AlternateText>Work at Dorknozzle!</AlternateText>
<Keyword>HR Sites</Keyword>
<Impressions>2</Impressions>
</Ad>
<Ad>
<ImageUrl>getthenewsletter.gif</ImageUrl>
<NavigateUrl>http://www.example.com</NavigateUrl>
<TargetUrl>_blank</TargetUrl>
<AlternateText>Get the nozzle newsletter</AlternateText>
<Keyword>HR Sites</Keyword>
<Impressions>1</Impressions>
</Ad>
</Advertisements>

<%@ Page Language=“VB” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=“http://www.w3.org/1999/xhtml”>
<head runat=“server”>
<title>Using the AdRotator control</title>
</head>
<body>
<form id=“form1” runat=“server”>
<div>
<asp:AdRotator ID=“adRotator” runat=“server”
AdvertisementFile=“Ads.xml” /> </div>
</form>
</body>
</html>

The “Ads.xml” give error msg- “file Ads.xml not found”

Thank you.


<asp:AdRotator ID="adRotator" runat="server"
    AdvertisementFile="Ads.xml"  />


Should be:



<asp:AdRotator ID="adRotator" runat="server"
    Target="_blank" AdvertisementFile="Ads.xml"  />



Take the <TargetUrl> out of the XML file, and add it to the <asp:AdRotator> control

Hope it helps.

Hi wwb99,

I am sorry the last suggesstion does not work either and I cant figure out what’s wrong, because everything looks similar to what’s in the book.

Thank you

oh please somebody help!

All that looks good, can you copy and paste the exception you are getting? That might help demistify things . . .

PS: stupid cross-check, but do you have file extensions showing or not showing on your PC?

Server Error in ‘/WebSite3’ Application.

The AdRotator adRotator could not find the AdvertisementFile or the file is invalid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The AdRotator adRotator could not find the AdvertisementFile or the file is invalid.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The AdRotator adRotator could not find the AdvertisementFile or the file is invalid.]
System.Web.UI.WebControls.AdRotator.GetFileData(String fileName) +489
System.Web.UI.WebControls.AdRotator.PerformAdFileBinding() +50
System.Web.UI.WebControls.AdRotator.OnPreRender(EventArgs e) +44
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


Version Information: Microsoft

It is looking for the Advertisement file!

So my questions is how do i create this link?

Thank you.

have you tried putting the full adress of the xml file in the code - eg “C:/ads.xml” or “www.example.com/ads.xml

Try:

AdvertisementFile=‘<%= Server.MapPath(“~/ads.xml”)%>’

Well, that’s a bit useless. Can you run it in the debugger and get the inner exception?

I ran into the same problem but I figured it out. You need to change the capital Ads.xml to ads.xml since this is what u saved the file with. My question is where can I download the gif images specified in the code. That is what I need to get it work for me. I don’t receive any error…only that image that I used is not displaying…it instead displays alternate text. Can anybody tell me how to download the images? getthenewsletter.gif & workatdorknozzle.gif. Thanks

@jasman110

I attached the 2 image files and left a link to the book’s Code Archive in your other thread.

Thanks so much. I downloaded the attachments and the page is now working fine. But I still can’t find the code archive. I bought the book already. In it there there were zip file which contains PDF version of the book, and these other 2 file type that I can not open aspnet3.mobi & aspnet3.epub. I think perhaps they have the same content as the pdf. Are they the code archives? if they are, how do I open them? many thanks

oh sorry!! I found the link to the archive on the page. Thanks for helping me jump this hurdle!