Help! I can't seem to fix this

View: New views
4 Messages — Rating Filter:   Alert me  

Help! I can't seem to fix this

by bdensmore :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 I have a clients site that gets it's delivery dates from a data feed from a 3rd party site. The data is returned in XML format. Everything has worked fine for months and then yesterday we started getting an error that "The Root Element was missing"

As a test I went to the url of the data feed to look at the XML that was being generated and copied it to a local file, I then updated my code to read from the local file and it worked fine. Can someone take a look at my code below and the XML being returned and see if they can find something wrong?

Thanks,
Ben

<Begin code>
// Get the next available delivery date
                XmlTextReader xmlReader = new XmlTextReader("http://xml.mysite.com/xmlrequest/GenerateDateList.asp?User=user&Pass=pass&p1=" + myProductDetails.ModelNumber.ToString() + "&output=XML");

                if (!IsPostBack)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(xmlReader);
               
                    XmlElement RootNode = doc.DocumentElement;
                    XmlNodeList nodeList = RootNode.GetElementsByTagName("DateValue");
               
                    for (int i = 0; i<nodeList.Count; i++)
                    {
                        DeliveryDate.Items.Add(new ListItem(nodeList.Item(i).InnerXml, nodeList.Item(i).InnerXml));
               
                    }
</ End Code>

<Begin XML>

<?xml version="1.0" encoding="UTF-8"?>
  <DateList>
   <DateValue>08/16/2005</DateValue>
   <DateValue>08/17/2005</DateValue>
   <DateValue>08/18/2005</DateValue>
   <DateValue>08/19/2005</DateValue>
   <DateValue>08/20/2005</DateValue>
   <DateValue>08/23/2005</DateValue>
   <DateValue>08/24/2005</DateValue>
   <DateValue>08/25/2005</DateValue>
   <DateValue>08/26/2005</DateValue>
   <DateValue>08/27/2005</DateValue>
   <DateValue>08/30/2005</DateValue>
   <DateValue>08/31/2005</DateValue>
   <DateValue>09/01/2005</DateValue>
   <DateValue>09/02/2005</DateValue>
   <DateValue>09/03/2005</DateValue>
   <DateValue>09/07/2005</DateValue>
   <DateValue>09/08/2005</DateValue>
   <DateValue>09/09/2005</DateValue>
   <DateValue>09/10/2005</DateValue>
   <DateValue>09/13/2005</DateValue>
   <DateValue>09/14/2005</DateValue>
   <DateValue>09/15/2005</DateValue>
   <DateValue>09/16/2005</DateValue>
   <DateValue>09/17/2005</DateValue>
   <DateValue>09/20/2005</DateValue>
   <DateValue>09/21/2005</DateValue>
   <DateValue>09/22/2005</DateValue>
   <DateValue>09/23/2005</DateValue>
   <DateValue>09/24/2005</DateValue>
   <DateValue>09/27/2005</DateValue>
   <DateValue>09/28/2005</DateValue>
   <DateValue>09/29/2005</DateValue>
   <DateValue>09/30/2005</DateValue>
   <DateValue>10/01/2005</DateValue>
   <DateValue>10/04/2005</DateValue>
   <DateValue>10/05/2005</DateValue>
   <DateValue>10/06/2005</DateValue>
   <DateValue>10/07/2005</DateValue>
   <DateValue>10/08/2005</DateValue>
   <DateValue>10/11/2005</DateValue>
   <DateValue>10/12/2005</DateValue>
   <DateValue>10/13/2005</DateValue>
   <DateValue>10/14/2005</DateValue>
   <DateValue>10/15/2005</DateValue>
   <DateValue>10/18/2005</DateValue>
   <DateValue>10/19/2005</DateValue>
   <DateValue>10/20/2005</DateValue>
   <DateValue>10/21/2005</DateValue>
   <DateValue>10/22/2005</DateValue>
   <DateValue>10/25/2005</DateValue>
</DateList>



</End XML>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get Instant Hacker Protection, Virus Detection, Antispam & Personal Firewall.
http://www.houseoffusion.com/banners/view.cfm?bannerid=62

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1796
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Re: Help! I can't seem to fix this

by G-14 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is it possible that an empty file could be returned???

Perhaps the root node was indeed not present for this reason, or some other
reason. Either way, your code should probably contain a built-in fail safe
should the root node not be present.

Since the code has always worked, and the variable here is the XML being
returned from the feed, something unexpected must have occurred in the feed,
and your code will probably need to be updated to continue gracefully in
that scenario.

One other thing, a try/catch block here could be very valuable in emailing
you information should the error occurr again.

> I have a clients site that gets it's delivery dates from a data feed from
> a 3rd party site. The data is returned in XML format. Everything has
> worked fine for months and then yesterday we started getting an error that
> "The Root Element was missing"
>
> As a test I went to the url of the data feed to look at the XML that was
> being generated and copied it to a local file, I then updated my code to
> read from the local file and it worked fine. Can someone take a look at my
> code below and the XML being returned and see if they can find something
> wrong?
>
> Thanks,
> Ben
>
> <Begin code>
> // Get the next available delivery date
>                XmlTextReader xmlReader = new
> XmlTextReader("http://xml.mysite.com/xmlrequest/GenerateDateList.asp?User=user&Pass=pass&p1="
> + myProductDetails.ModelNumber.ToString() + "&output=XML");
>
>                if (!IsPostBack)
>                {
>                    XmlDocument doc = new XmlDocument();
>                    doc.Load(xmlReader);
>
>                    XmlElement RootNode = doc.DocumentElement;
>                    XmlNodeList nodeList =
> RootNode.GetElementsByTagName("DateValue");
>
>                    for (int i = 0; i<nodeList.Count; i++)
>                    {
>                        DeliveryDate.Items.Add(new
> ListItem(nodeList.Item(i).InnerXml, nodeList.Item(i).InnerXml));
>
>                    }
> </ End Code>
>
> <Begin XML>
>
> <?xml version="1.0" encoding="UTF-8"?>
>  <DateList>
>   <DateValue>08/16/2005</DateValue>
>   <DateValue>08/17/2005</DateValue>
>   <DateValue>08/18/2005</DateValue>
>   <DateValue>08/19/2005</DateValue>
>   <DateValue>08/20/2005</DateValue>
>   <DateValue>08/23/2005</DateValue>
>   <DateValue>08/24/2005</DateValue>
>   <DateValue>08/25/2005</DateValue>
>   <DateValue>08/26/2005</DateValue>
>   <DateValue>08/27/2005</DateValue>
>   <DateValue>08/30/2005</DateValue>
>   <DateValue>08/31/2005</DateValue>
>   <DateValue>09/01/2005</DateValue>
>   <DateValue>09/02/2005</DateValue>
>   <DateValue>09/03/2005</DateValue>
>   <DateValue>09/07/2005</DateValue>
>   <DateValue>09/08/2005</DateValue>
>   <DateValue>09/09/2005</DateValue>
>   <DateValue>09/10/2005</DateValue>
>   <DateValue>09/13/2005</DateValue>
>   <DateValue>09/14/2005</DateValue>
>   <DateValue>09/15/2005</DateValue>
>   <DateValue>09/16/2005</DateValue>
>   <DateValue>09/17/2005</DateValue>
>   <DateValue>09/20/2005</DateValue>
>   <DateValue>09/21/2005</DateValue>
>   <DateValue>09/22/2005</DateValue>
>   <DateValue>09/23/2005</DateValue>
>   <DateValue>09/24/2005</DateValue>
>   <DateValue>09/27/2005</DateValue>
>   <DateValue>09/28/2005</DateValue>
>   <DateValue>09/29/2005</DateValue>
>   <DateValue>09/30/2005</DateValue>
>   <DateValue>10/01/2005</DateValue>
>   <DateValue>10/04/2005</DateValue>
>   <DateValue>10/05/2005</DateValue>
>   <DateValue>10/06/2005</DateValue>
>   <DateValue>10/07/2005</DateValue>
>   <DateValue>10/08/2005</DateValue>
>   <DateValue>10/11/2005</DateValue>
>   <DateValue>10/12/2005</DateValue>
>   <DateValue>10/13/2005</DateValue>
>   <DateValue>10/14/2005</DateValue>
>   <DateValue>10/15/2005</DateValue>
>   <DateValue>10/18/2005</DateValue>
>   <DateValue>10/19/2005</DateValue>
>   <DateValue>10/20/2005</DateValue>
>   <DateValue>10/21/2005</DateValue>
>   <DateValue>10/22/2005</DateValue>
>   <DateValue>10/25/2005</DateValue>
> </DateList>
>
>
>
> </End XML>
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Sams Teach Yourself Regular Expressions in 10 Minutes  by Ben Forta
http://www.houseoffusion.com/banners/view.cfm?bannerid=40

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1797
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Re: Help! I can't seem to fix this

by bdensmore :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It is actually in a try catch block, I just didn't include that. I get
an email for every error generated. This is what's being sent in the
email for the error.

[modelnumber=9066]System.Xml.XmlException: The root element is missing.
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at RoseMasters_com.ProductDetailsPage.Page_Load(Object sender, EventArgs e)

I will do some other testing and see if the xml file is being returned empty.

Thanks for the ideas.

Ben

On 8/18/05, G <brian.grant@...> wrote:

> Is it possible that an empty file could be returned???
>
> Perhaps the root node was indeed not present for this reason, or some other
> reason. Either way, your code should probably contain a built-in fail safe
> should the root node not be present.
>
> Since the code has always worked, and the variable here is the XML being
> returned from the feed, something unexpected must have occurred in the feed,
> and your code will probably need to be updated to continue gracefully in
> that scenario.
>
> One other thing, a try/catch block here could be very valuable in emailing
> you information should the error occurr again.
>
> > I have a clients site that gets it's delivery dates from a data feed from
> > a 3rd party site. The data is returned in XML format. Everything has
> > worked fine for months and then yesterday we started getting an error that
> > "The Root Element was missing"
> >
> > As a test I went to the url of the data feed to look at the XML that was
> > being generated and copied it to a local file, I then updated my code to
> > read from the local file and it worked fine. Can someone take a look at my
> > code below and the XML being returned and see if they can find something
> > wrong?
> >
> > Thanks,
> > Ben
> >
> > <Begin code>
> > // Get the next available delivery date
> >                XmlTextReader xmlReader = new
> > XmlTextReader("http://xml.mysite.com/xmlrequest/GenerateDateList.asp?User=user&Pass=pass&p1="
> > + myProductDetails.ModelNumber.ToString() + "&output=XML");
> >
> >                if (!IsPostBack)
> >                {
> >                    XmlDocument doc = new XmlDocument();
> >                    doc.Load(xmlReader);
> >
> >                    XmlElement RootNode = doc.DocumentElement;
> >                    XmlNodeList nodeList =
> > RootNode.GetElementsByTagName("DateValue");
> >
> >                    for (int i = 0; i<nodeList.Count; i++)
> >                    {
> >                        DeliveryDate.Items.Add(new
> > ListItem(nodeList.Item(i).InnerXml, nodeList.Item(i).InnerXml));
> >
> >                    }
> > </ End Code>
> >
> > <Begin XML>
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >  <DateList>
> >   <DateValue>08/16/2005</DateValue>
> >   <DateValue>08/17/2005</DateValue>
> >   <DateValue>08/18/2005</DateValue>
> >   <DateValue>08/19/2005</DateValue>
> >   <DateValue>08/20/2005</DateValue>
> >   <DateValue>08/23/2005</DateValue>
> >   <DateValue>08/24/2005</DateValue>
> >   <DateValue>08/25/2005</DateValue>
> >   <DateValue>08/26/2005</DateValue>
> >   <DateValue>08/27/2005</DateValue>
> >   <DateValue>08/30/2005</DateValue>
> >   <DateValue>08/31/2005</DateValue>
> >   <DateValue>09/01/2005</DateValue>
> >   <DateValue>09/02/2005</DateValue>
> >   <DateValue>09/03/2005</DateValue>
> >   <DateValue>09/07/2005</DateValue>
> >   <DateValue>09/08/2005</DateValue>
> >   <DateValue>09/09/2005</DateValue>
> >   <DateValue>09/10/2005</DateValue>
> >   <DateValue>09/13/2005</DateValue>
> >   <DateValue>09/14/2005</DateValue>
> >   <DateValue>09/15/2005</DateValue>
> >   <DateValue>09/16/2005</DateValue>
> >   <DateValue>09/17/2005</DateValue>
> >   <DateValue>09/20/2005</DateValue>
> >   <DateValue>09/21/2005</DateValue>
> >   <DateValue>09/22/2005</DateValue>
> >   <DateValue>09/23/2005</DateValue>
> >   <DateValue>09/24/2005</DateValue>
> >   <DateValue>09/27/2005</DateValue>
> >   <DateValue>09/28/2005</DateValue>
> >   <DateValue>09/29/2005</DateValue>
> >   <DateValue>09/30/2005</DateValue>
> >   <DateValue>10/01/2005</DateValue>
> >   <DateValue>10/04/2005</DateValue>
> >   <DateValue>10/05/2005</DateValue>
> >   <DateValue>10/06/2005</DateValue>
> >   <DateValue>10/07/2005</DateValue>
> >   <DateValue>10/08/2005</DateValue>
> >   <DateValue>10/11/2005</DateValue>
> >   <DateValue>10/12/2005</DateValue>
> >   <DateValue>10/13/2005</DateValue>
> >   <DateValue>10/14/2005</DateValue>
> >   <DateValue>10/15/2005</DateValue>
> >   <DateValue>10/18/2005</DateValue>
> >   <DateValue>10/19/2005</DateValue>
> >   <DateValue>10/20/2005</DateValue>
> >   <DateValue>10/21/2005</DateValue>
> >   <DateValue>10/22/2005</DateValue>
> >   <DateValue>10/25/2005</DateValue>
> > </DateList>
> >
> >
> >
> > </End XML>
> >
> >
> >
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase Homesite Plus with Dreamweaver from House of Fusion, a Macromedia Authorized Affiliate and support the CF community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=55

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1798
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Re: Help! I can't seem to fix this

by bdensmore :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It is actually in a try catch block, I just didn't include that. I get
an email for every error generated. This is what's being sent in the
email for the error.

[modelnumber=9066]System.Xml.XmlException: The root element is missing.
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at RoseMasters_com.ProductDetailsPage.Page_Load(Object sender, EventArgs e)

I will do some other testing and see if the xml file is being returned empty.

Thanks for the ideas.

Ben

On 8/18/05, G <brian.grant@...> wrote:

> Is it possible that an empty file could be returned???
>
> Perhaps the root node was indeed not present for this reason, or some other
> reason. Either way, your code should probably contain a built-in fail safe
> should the root node not be present.
>
> Since the code has always worked, and the variable here is the XML being
> returned from the feed, something unexpected must have occurred in the feed,
> and your code will probably need to be updated to continue gracefully in
> that scenario.
>
> One other thing, a try/catch block here could be very valuable in emailing
> you information should the error occurr again.
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:44:1799
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/44
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:44
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.44
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54