Reading from XML file
-
Hi I'm trying to build a program which will read and assign to variables the values from an XML file which goes like this (without the *): <*n1> random number here <*/n1> <*n2> random number here <*/n2> I tried to use the XmlTextReader but I got an error when I passed the location of the file ("C:\\Documents and Settings\\myfile.xml") so I tried the XmlDocument and it's function SelectSingleNode("n1") but I got another error. So what's the best way to get the values from this XML file? (I also want to show an error message if the XML file is not built as I mentioned (<*n1> <*/n1> <*n2> <*/n2>). thanks
-
Hi I'm trying to build a program which will read and assign to variables the values from an XML file which goes like this (without the *): <*n1> random number here <*/n1> <*n2> random number here <*/n2> I tried to use the XmlTextReader but I got an error when I passed the location of the file ("C:\\Documents and Settings\\myfile.xml") so I tried the XmlDocument and it's function SelectSingleNode("n1") but I got another error. So what's the best way to get the values from this XML file? (I also want to show an error message if the XML file is not built as I mentioned (<*n1> <*/n1> <*n2> <*/n2>). thanks
gibsray wrote:
but I got an error when I passed the location of the file I tried the XmlDocument and it's function SelectSingleNode("n1") but I got another error.
We can't read your mind. What errors did you receive? /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Hi I'm trying to build a program which will read and assign to variables the values from an XML file which goes like this (without the *): <*n1> random number here <*/n1> <*n2> random number here <*/n2> I tried to use the XmlTextReader but I got an error when I passed the location of the file ("C:\\Documents and Settings\\myfile.xml") so I tried the XmlDocument and it's function SelectSingleNode("n1") but I got another error. So what's the best way to get the values from this XML file? (I also want to show an error message if the XML file is not built as I mentioned (<*n1> <*/n1> <*n2> <*/n2>). thanks
I very much doubt that your file is in the root of the Document and Settings folder. Perhaps you should double check that your path is valid.
I wasn't, now I am, then I won't be anymore.
-
Hi I'm trying to build a program which will read and assign to variables the values from an XML file which goes like this (without the *): <*n1> random number here <*/n1> <*n2> random number here <*/n2> I tried to use the XmlTextReader but I got an error when I passed the location of the file ("C:\\Documents and Settings\\myfile.xml") so I tried the XmlDocument and it's function SelectSingleNode("n1") but I got another error. So what's the best way to get the values from this XML file? (I also want to show an error message if the XML file is not built as I mentioned (<*n1> <*/n1> <*n2> <*/n2>). thanks
You need a root. You did not provide the error, so so not know what the exact issue is, but can only have one root node.
<items>
<*n1>random number here </*n1>
<*n2>random number here </*n2>
</items>Of course this is not good xml either. XML will object to the *, and there is no * before the backslash.
-
Hi I'm trying to build a program which will read and assign to variables the values from an XML file which goes like this (without the *): <*n1> random number here <*/n1> <*n2> random number here <*/n2> I tried to use the XmlTextReader but I got an error when I passed the location of the file ("C:\\Documents and Settings\\myfile.xml") so I tried the XmlDocument and it's function SelectSingleNode("n1") but I got another error. So what's the best way to get the values from this XML file? (I also want to show an error message if the XML file is not built as I mentioned (<*n1> <*/n1> <*n2> <*/n2>). thanks
Try this link http://support.microsoft.com/kb/307548[^] :)