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. C# & XML should take the blue pill ;-)

C# & XML should take the blue pill ;-)

Scheduled Pinned Locked Moved C#
xmlquestioncsharpdatabasebusiness
7 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.
  • A Offline
    A Offline
    antoine orchus tech
    wrote on last edited by
    #1

    Hi! My real name is Antoine Dubuc, and I'm screwed! :omg: I have an xml document with his sidekick schema, and they're both doing fine. There's this textbox that would like to be filled with data from our trusty XML file. So being ignominously screwed in attempting to muster some sense from F1 ( who writes this anyway!???) I am here to ask you some advice. How can I open my xml file, search it to find the right element, say 'First Name', and have it displayed inside the textbox? I know, you are probably thinking ... :laugh: ... I'm a beginner in XML, hence this qustion from which I'd be grateful to receive some specific code example ;) :) Thank you! Antoine Orchus Technologies Coding is a family business

    C K M 3 Replies Last reply
    0
    • A antoine orchus tech

      Hi! My real name is Antoine Dubuc, and I'm screwed! :omg: I have an xml document with his sidekick schema, and they're both doing fine. There's this textbox that would like to be filled with data from our trusty XML file. So being ignominously screwed in attempting to muster some sense from F1 ( who writes this anyway!???) I am here to ask you some advice. How can I open my xml file, search it to find the right element, say 'First Name', and have it displayed inside the textbox? I know, you are probably thinking ... :laugh: ... I'm a beginner in XML, hence this qustion from which I'd be grateful to receive some specific code example ;) :) Thank you! Antoine Orchus Technologies Coding is a family business

      C Offline
      C Offline
      Chris Maunder
      wrote on last edited by
      #2

      Use the .NET Xml* classes to load the XML file, then you can search through the resultant XML tree to find the right element, then (I assume you're doing this within the Page_Load event of an ASP.NET page) set the text of the appropriate text input element in your ASP.NET page by setting the TextBox.Text property as the value of the element in the XML tree. cheers, Chris Maunder

      A 1 Reply Last reply
      0
      • C Chris Maunder

        Use the .NET Xml* classes to load the XML file, then you can search through the resultant XML tree to find the right element, then (I assume you're doing this within the Page_Load event of an ASP.NET page) set the text of the appropriate text input element in your ASP.NET page by setting the TextBox.Text property as the value of the element in the XML tree. cheers, Chris Maunder

        A Offline
        A Offline
        antoine orchus tech
        wrote on last edited by
        #3

        The project for this is a Windows Form project. What classes ?! I mean, I'm a beginner, I tried XmlDataDocument and I load the xml file into it. Ok. Now, what do I use to search the right node and output the element to the textbox? :) Thank you :) Antoine Coding is a family business

        J 1 Reply Last reply
        0
        • A antoine orchus tech

          The project for this is a Windows Form project. What classes ?! I mean, I'm a beginner, I tried XmlDataDocument and I load the xml file into it. Ok. Now, what do I use to search the right node and output the element to the textbox? :) Thank you :) Antoine Coding is a family business

          J Offline
          J Offline
          J Dunlap
          wrote on last edited by
          #4

          Hi, The following code loads the text in the tag "/root/firstname" of the file "c:\xmlfile.xml" into a textbox named "FirstNametextbox".

          System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

          xmlDoc.Load(@"c:\xmlfile.xml");
          XmlNode node = xmlDoc.SelectSingleNode(@"/root/firstname");
          FirstNametextbox.Text=node.InnerText;

          HTH, J Dunlap

          "Do unto others as you would have them do unto you." - Jesus
          "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

          A 1 Reply Last reply
          0
          • A antoine orchus tech

            Hi! My real name is Antoine Dubuc, and I'm screwed! :omg: I have an xml document with his sidekick schema, and they're both doing fine. There's this textbox that would like to be filled with data from our trusty XML file. So being ignominously screwed in attempting to muster some sense from F1 ( who writes this anyway!???) I am here to ask you some advice. How can I open my xml file, search it to find the right element, say 'First Name', and have it displayed inside the textbox? I know, you are probably thinking ... :laugh: ... I'm a beginner in XML, hence this qustion from which I'd be grateful to receive some specific code example ;) :) Thank you! Antoine Orchus Technologies Coding is a family business

            K Offline
            K Offline
            Karavaev Denis
            wrote on last edited by
            #5

            Try this: http://www.codeproject.com/csharp/app\_config.asp ===================== http://wasp.elcat.kg

            1 Reply Last reply
            0
            • J J Dunlap

              Hi, The following code loads the text in the tag "/root/firstname" of the file "c:\xmlfile.xml" into a textbox named "FirstNametextbox".

              System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

              xmlDoc.Load(@"c:\xmlfile.xml");
              XmlNode node = xmlDoc.SelectSingleNode(@"/root/firstname");
              FirstNametextbox.Text=node.InnerText;

              HTH, J Dunlap

              "Do unto others as you would have them do unto you." - Jesus
              "An eye for an eye only makes the whole world blind." - Mahatma Gandhi

              A Offline
              A Offline
              antoine orchus tech
              wrote on last edited by
              #6

              Thank you very much! :) Antoine Coding is a family business

              1 Reply Last reply
              0
              • A antoine orchus tech

                Hi! My real name is Antoine Dubuc, and I'm screwed! :omg: I have an xml document with his sidekick schema, and they're both doing fine. There's this textbox that would like to be filled with data from our trusty XML file. So being ignominously screwed in attempting to muster some sense from F1 ( who writes this anyway!???) I am here to ask you some advice. How can I open my xml file, search it to find the right element, say 'First Name', and have it displayed inside the textbox? I know, you are probably thinking ... :laugh: ... I'm a beginner in XML, hence this qustion from which I'd be grateful to receive some specific code example ;) :) Thank you! Antoine Orchus Technologies Coding is a family business

                M Offline
                M Offline
                Manster
                wrote on last edited by
                #7

                Add the using System.Xml; line of code to the top of your project. This will allow you to use most of the xml .Net classes. The XmlDocument, XmlNode, XmlNodeList, XmlElement, and XmlAttribute classes are the ones you'll use the most.

                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