.NETGURU
file path issues in reading an xml file using XMLDataDocument
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Venky (VIP)
I would like another pair of eyes to look at this. Any comments really
appreciated.

Here is my code snippet....

Label Header = new Label();
Header.ForeColor =System.Drawing.Color.RoyalBlue;
Header.Font.Size = 14;
Header.Font.Italic = false;
Header.Text = "Test Table ";
Header.RenderControl(output);
            
Table ATable = new Table();
XmlDataDocument XMLD = new XmlDataDocument ();
        
try
{
XMLD.DataSet.ReadXml(Location); // Location = "c:\test.xml"
XmlNodeList col = XMLD.ChildNodes[0].ChildNodes;
    foreach(XmlNode oNode in col)
{
     XmlNodeList col2 = oNode.ChildNodes;
     Add2Table(col2[0].InnerText, col2[1].InnerText,ref ATable);
    }
            
    ATable.BorderStyle = System.Web.UI.WebControls.BorderStyle.Groove;
    ATable.BorderColor = System.Drawing.Color.DarkBlue;
    ATable.RenderControl(output);
}
catch
{
                
    output.Write(XMLD.ChildNodes.Count);
    output.Write(Location);
    output.Write("Problem with XML file");
}

my xml file at c:\test.xml
<?xml version="1.0" standalone="yes" ?>
<Test>
<Ranking>
    <Rank>1</Rank>
    <Business><Heat Pumps></Business>
</Ranking>
<Ranking>
    <Rank>2</Rank>
    <Business><Boilers></Business>
</Ranking>
</Test>

My code keeps breaking when i supply c:\test.xml as the file path.
Am I totally off the wall on this?

Any comment is appreciated.

Thx
Click here to reveal e-mail address
Reply to this message...
 
    
vinay (VIP)
<Heat Pumps> and ><Boilers> dosent have closing tags!!

"Venky" wrote:

[Original message clipped]

Reply to this message...
 
    
venky (VIP)
Sorry Vinay this is actual data. My bad.

The file should read as below. However I still the get the error on the line
: "XMLD.DataSet.ReadXml(Location);" I wonder if i need to prefix the string
Location with something like a @?

<?xml version="1.0" standalone="yes" ?>
<Test>
<Ranking>
    <Rank>1</Rank>
    <Business>Heat Pumps</Business>
</Ranking>
<Ranking>
    <Rank>2</Rank>
    <Business>Boilers</Business>
</Ranking>
</Test>

"vinay" wrote:

[Original message clipped]

Reply to this message...
 
    
vinay (VIP)
string Location = @"c:\test.xml";
OR
string Location = "c:\\test.xml";

Vinay

"venky" wrote:

[Original message clipped]

Reply to this message...
 
    
Venky (VIP)
The error happens on this line - XMLD.DataSet.ReadXml(Location);

"Venky" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Drawing.Color
System.Reflection.Emit.Label
System.Runtime.Remoting.Messaging.Header
System.Web.UI.MobileControls.Label
System.Web.UI.WebControls.BorderStyle
System.Web.UI.WebControls.Label
System.Web.UI.WebControls.Table
System.Windows.Forms.Label
System.Xml.XmlDataDocument
System.Xml.XmlNode
System.Xml.XmlNodeList




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification