Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reading from XML file

Reading from XML file

Scheduled Pinned Locked Moved C#
xmlhelpquestionlounge
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gibsray
    wrote on last edited by
    #1

    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

    R F C G 4 Replies Last reply
    0
    • G gibsray

      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

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • G gibsray

        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

        F Offline
        F Offline
        fjdiewornncalwe
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • G gibsray

          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

          C Offline
          C Offline
          Clifford Nelson
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • G gibsray

            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

            G Offline
            G Offline
            gopal pradhan
            wrote on last edited by
            #5

            Try this link http://support.microsoft.com/kb/307548[^] :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups