How to debug a file not being written? (XML)

  • Thread starter Thread starter Darrel
  • Start date Start date
D

Darrel

I'm creating a recursive function that goes into a database and pulls
everything out as an XML file. I then want to save thisXML file on the
server.

I have this:

xmldoc.Save(Server.MapPath("siteMenu.xml"))

My SUB seems to execute fine. No errors. But I don't end up with a file,
either. How do I go about debugging this?
 
Maybe the file is being written somewhere other than where you think it is. Break the line into two statements:

string s = Server.MapPath("siteMenu.xml")
xmlDoc.Save(s)

Now you can check where s refers to

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

I'm creating a recursive function that goes into a database and pulls
everything out as an XML file. I then want to save thisXML file on the
server.

I have this:

xmldoc.Save(Server.MapPath("siteMenu.xml"))

My SUB seems to execute fine. No errors. But I don't end up with a file,
either. How do I go about debugging this?
 
Maybe the file is being written somewhere other than where you think it
is. Break the line into two statements:

Ugh. My fault. It was throwing an error, I just wasn't catching it properly.

So, and this may be a dumb question, how do I get a more detailed error from
my catch statement?

Here's the line that is throwing the error:

eleMenuItems = xmldoc.CreateElement("menuItems")
xmldoc.DocumentElement.PrependChild(eleMenuItems)

It's the second line that is causing the problem.

-Darrel
 
Again, to fully understand what is generating an error you need to breakdown compound statements.

xmldoc.DocumentElement.PrependChild(eleMenuItems)

is really two statements

Dim n as XmlNode
n = xmldoc.DocumentElement
n.PrependChild(eleMenuItems)

This way you'd realise very quickly that the DocumentElement is returning Nothing. In production there is no problem having compound statements, just when yoou are trying to debug and can't figure out what is throwing the exception, its a good idea to break them down.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

Here's the line that is throwing the error:

eleMenuItems = xmldoc.CreateElement("menuItems")
xmldoc.DocumentElement.PrependChild(eleMenuItems)

It's the second line that is causing the problem.

-Darrel





---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.775 / Virus Database: 522 - Release Date: 08/10/2004



[microsoft.public.dotnet.framework]
 
Back
Top