mubama0n
asked on
Loading And Reading XML file from Virtual folder
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?
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?
use the WebRequest and WebResponse classes to download the file, you can then parse it with XML and/or XPath
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
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
ASKER
Ok Is the Xml Document in the question Is right or I should modify it?
ASKER
Look How I can read the document On the question?
ASKER
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>
<?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>
ASKER
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?
<add key="ver" value="1.1.1.3"/>
On the Version section How I can do it?
ASKER
I deont want to read it as ad data set , I want to read section and get its value?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
ASKER
I found run time error when loading the document said :
System Error.
I'm sure from the name (server hosts xml) is right name .
System Error.
I'm sure from the name (server hosts xml) is right name .
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
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
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
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
ASKER
windows application , please refer to this link and try to share answer:
https://www.experts-exchange.com/questions/21349653/loading-XML-document-from-Virtual-folder.html
Thanks
https://www.experts-exchange.com/questions/21349653/loading-XML-document-from-Virtual-folder.html
Thanks
ASKER
About (BTW, dont' ask more than a question per thread, it's against EE rules) , you are right I'm sorry.