Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Loading And Reading XML file from Virtual folder

Posted on 2005-03-13
14
Medium Priority
?
255 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

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.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

580 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