?
Solved

Loading And Reading XML file from Virtual folder

Posted on 2005-03-13
14
Medium Priority
?
238 Views
Last Modified: 2010-04-16
Hi ,

I have the following xml document (App.XML)

<?xml version="1.0" encoding="Windows-1252" ?>
<configuration>
<application>
<add key="filename" value="myapp.exe"/>
</application>
<mainhostname>
<add key="address" value=""/>
</mainhostname>
<versions>
<add key="ver" value="1.0.0.0"/>
<add key="ver" value="1.1.1.1"/>
<add key="ver" value="1.1.1.2"/>
</versions>
<v1.0.0.0>
<add key="FC" value="D:\practic\The Execution Program\111.txt" value1="@"/>
<add key="FC" value="D:\practic\The Execution Program\Mapx.dll" value1="@"/>
<add key="CD" value="CMY" value1=""/>
</v1.0.0.0>
<v1.1.1.1>
</v1.1.1.1>
<intreface>
</intreface>
</configuration>
/---->

This XML file located in a Virtual folder ("http://localhost/SampleUpdate/app.xml") , I want a code that load and then read this file from the virtual folder?
0
Comment
Question by:mubama0n
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
14 Comments
 
LVL 10

Expert Comment

by:makerp
ID: 13528175
use the WebRequest and WebResponse classes to download the file, you can then parse it with XML and/or XPath
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13528490
Hello


you can read it directly using Dataset

DataSet ds = new DataSet();
ds.ReadXml("http://localhost/SampleUpdate/app.xml")
dataGrid1.DataSource = ds.Tables[0];

Even you could do that to read from web also

DataSet ds = new DataSet();
ds.ReadXml("http://www.w3schools.com/xml/note.xml");
dataGrid1.DataSource = ds.Tables[0];

Regards,
Mohammed Nasman
0
 

Author Comment

by:mubama0n
ID: 13528507
Ok Is the Xml Document in the question Is right or I should modify it?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:mubama0n
ID: 13528512
Look How I can read the document On the question?
0
 

Author Comment

by:mubama0n
ID: 13528513
The On Here :
<?xml version="1.0" encoding="Windows-1252" ?>
<configuration>
<application>
<add key="filename" value="myapp.exe"/>
</application>
<mainhostname>
<add key="address" value=""/>
</mainhostname>
<versions>
<add key="ver" value="1.0.0.0"/>
<add key="ver" value="1.1.1.1"/>
<add key="ver" value="1.1.1.2"/>
</versions>
<v1.0.0.0>
<add key="FC" value="D:\practic\The Execution Program\111.txt" value1="@"/>
<add key="FC" value="D:\practic\The Execution Program\Mapx.dll" value1="@"/>
<add key="CD" value="CMY" value1=""/>
</v1.0.0.0>
<v1.1.1.1>
</v1.1.1.1>
<intreface>
</intreface>
</configuration>
0
 

Author Comment

by:mubama0n
ID: 13528518
If Want to Append A lin on Any section , Lets say I want to append:
<add key="ver" value="1.1.1.3"/>
On the Version section How I can do it?
0
 

Author Comment

by:mubama0n
ID: 13528525
I deont want to read it as ad data set , I want to read section and get its value?
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 1000 total points
ID: 13528550
you can use XmlDocument to read it in the same way, Your file will not work with dataset

            XmlDocument xml = new XmlDocument();
            xml.Load("http://localhost/SampleUpdate/app.xml");
            MessageBox.Show(xml.OuterXml);
0
 

Author Comment

by:mubama0n
ID: 13528579
Q. Is the structure of this document (On the question) is correct or I Should Append or modify something to it?

Q.If Want to Append A lin on Any section , Lets say I want to append:
<add key="ver" value="1.1.1.3"/>
On the Version section How I can do it?


0
 

Author Comment

by:mubama0n
ID: 13534086
I found run time error when loading the document said :
System Error.

I'm sure from the name (server hosts xml) is right name .
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13534173
sorry for late reply

Q1. yes, you could be insure from the structure by open the file using Internet Explorer, if it's valid it will show it without problem

Q2. You have to work with XMLElement and XmlNode, msdn help have some examples, I don't work a lot with XMLDocument, so I don't have an example in hand now

BTW, dont' ask more than a question per thread, it's against EE rules

HTH
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13534184
oh sorry

for that last comment you have to give more details, do you use windows or web application?

also put the load statment in try.. catch and look for the exception that you get
0
 

Author Comment

by:mubama0n
ID: 13534801
windows application , please refer to this link and try to share answer:
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21349653.html

Thanks
0
 

Author Comment

by:mubama0n
ID: 13534840
About (BTW, dont' ask more than a question per thread, it's against EE rules) , you are right I'm sorry.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question