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. XML in C#

XML in C#

Scheduled Pinned Locked Moved C#
questioncsharpxmlhelplounge
8 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.
  • K Offline
    K Offline
    Kris100
    wrote on last edited by
    #1

    Hello Coders! This is quite a general question, I’m just looking for a point in the right direction Is there any way you can “view” an xml document on a C# Form? By this I mean each element shown on various controls and then a next and previous button to cycle through the XML Nodes? i have tried various things with XMLDocument, XMLNode and XMLElement but have had no avail, and i was just wondering if there was a set way to do it. The XML file contains Portfolio items that have a name, description and an image link. Thanks for any help Kris

    M A C K 4 Replies Last reply
    0
    • K Kris100

      Hello Coders! This is quite a general question, I’m just looking for a point in the right direction Is there any way you can “view” an xml document on a C# Form? By this I mean each element shown on various controls and then a next and previous button to cycle through the XML Nodes? i have tried various things with XMLDocument, XMLNode and XMLElement but have had no avail, and i was just wondering if there was a set way to do it. The XML file contains Portfolio items that have a name, description and an image link. Thanks for any help Kris

      M Offline
      M Offline
      max29297
      wrote on last edited by
      #2

      I don't know a lot about XML in C#, but since the XML file is encoded using ASCII you should be able to store the xml file in a string then filter it out. That probably doesn't help, but it might work.

      ----- *** Never give me an answer having anything to do with Visual Studio. I don't have this because I have two computers, one being my dad's mac, which is connected to the internet, the other being my pc, which is, sadly, not connected to the internet. The setup for the Visual C# program I think is called a "bootstrap" program, and it needs to connect to the internet to install the program. THEREFORE I cannot install this program onto my pc.***

      1 Reply Last reply
      0
      • K Kris100

        Hello Coders! This is quite a general question, I’m just looking for a point in the right direction Is there any way you can “view” an xml document on a C# Form? By this I mean each element shown on various controls and then a next and previous button to cycle through the XML Nodes? i have tried various things with XMLDocument, XMLNode and XMLElement but have had no avail, and i was just wondering if there was a set way to do it. The XML file contains Portfolio items that have a name, description and an image link. Thanks for any help Kris

        A Offline
        A Offline
        Amit Kumar G
        wrote on last edited by
        #3

        I am not very clear with your question. But it seems like you want to populate node values in controls. If i am correct then, you can use Xpath and it is pretty straightforward. In case you need any source code please let me know... Thanks Amit

        1 Reply Last reply
        0
        • K Kris100

          Hello Coders! This is quite a general question, I’m just looking for a point in the right direction Is there any way you can “view” an xml document on a C# Form? By this I mean each element shown on various controls and then a next and previous button to cycle through the XML Nodes? i have tried various things with XMLDocument, XMLNode and XMLElement but have had no avail, and i was just wondering if there was a set way to do it. The XML file contains Portfolio items that have a name, description and an image link. Thanks for any help Kris

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          One option is to host IE as a control, it displays XML with +/- buttons for the parent nodes. Otherwise, you need to write your own control, or search the web. The classes you mention are for iterating over XML, and they work just fine, they have nothing to do with displaying it, however.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          M 1 Reply Last reply
          0
          • C Christian Graus

            One option is to host IE as a control, it displays XML with +/- buttons for the parent nodes. Otherwise, you need to write your own control, or search the web. The classes you mention are for iterating over XML, and they work just fine, they have nothing to do with displaying it, however.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            M Offline
            M Offline
            Mark Greenwood
            wrote on last edited by
            #5

            Use this control http://www.codeproject.com/cs/miscctrl/Siepe_XmlTreeView.asp[^] You just throw an XmlDocument at it and it shows all the nodes as a tree style control I've used it - it has editing etc built in Mark.

            1 Reply Last reply
            0
            • K Kris100

              Hello Coders! This is quite a general question, I’m just looking for a point in the right direction Is there any way you can “view” an xml document on a C# Form? By this I mean each element shown on various controls and then a next and previous button to cycle through the XML Nodes? i have tried various things with XMLDocument, XMLNode and XMLElement but have had no avail, and i was just wondering if there was a set way to do it. The XML file contains Portfolio items that have a name, description and an image link. Thanks for any help Kris

              K Offline
              K Offline
              Kris100
              wrote on last edited by
              #6

              Cheers for the replies guys! Sorry, I think i was being a bit vague before. What I’m attempting to do is take an XML file that is structured like so:- Title Description imageURL Title Description imageURL ...etc and displaying the info in separate controls...to the Title in a Textbox and the Image in an Image etc. Then, using 2 buttons, cycle through (left and right) through the items. its getting the XML into the program I’m having difficulty with, what I want to do is load each Item into an object instance, then put those instances into an ArrayList or something. I’m very new to the .net framework and have tried different things but getting nowhere. any further help would be fantasic Thanks again Kris

              M 1 Reply Last reply
              0
              • K Kris100

                Cheers for the replies guys! Sorry, I think i was being a bit vague before. What I’m attempting to do is take an XML file that is structured like so:- Title Description imageURL Title Description imageURL ...etc and displaying the info in separate controls...to the Title in a Textbox and the Image in an Image etc. Then, using 2 buttons, cycle through (left and right) through the items. its getting the XML into the program I’m having difficulty with, what I want to do is load each Item into an object instance, then put those instances into an ArrayList or something. I’m very new to the .net framework and have tried different things but getting nowhere. any further help would be fantasic Thanks again Kris

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

                Okay, now that I am learned in the art of XML in C# ;), here's some code: using System; using System.IO; using System.Xml; using System.Collections; class Run {    static void Main() {       XmlTextReader reader = new XmlTextReader("file.xml");              ArrayList titles = new ArrayList();       ArrayList descriptions = new ArrayList();       ArrayList images = new ArrayList();              reader.MoveToContent();       while (reader.Read()) {          if (reader.NodeType == XmlNodeType.Element) {             switch (reader.Name) {                case "Title":                   titles.Add(reader.ReadString());                   break;                case "Description":                   descriptions.Add(reader.ReadString());                   break;                case "Image":                   images.Add(reader.ReadString());                   break;             }          }       }              for (int a = 0; a < titles.Count; a++) {          Console.WriteLine("-----" + titles[a] + "-----");          Console.WriteLine(descriptions[a]);

                M 1 Reply Last reply
                0
                • M max29297

                  Okay, now that I am learned in the art of XML in C# ;), here's some code: using System; using System.IO; using System.Xml; using System.Collections; class Run {    static void Main() {       XmlTextReader reader = new XmlTextReader("file.xml");              ArrayList titles = new ArrayList();       ArrayList descriptions = new ArrayList();       ArrayList images = new ArrayList();              reader.MoveToContent();       while (reader.Read()) {          if (reader.NodeType == XmlNodeType.Element) {             switch (reader.Name) {                case "Title":                   titles.Add(reader.ReadString());                   break;                case "Description":                   descriptions.Add(reader.ReadString());                   break;                case "Image":                   images.Add(reader.ReadString());                   break;             }          }       }              for (int a = 0; a < titles.Count; a++) {          Console.WriteLine("-----" + titles[a] + "-----");          Console.WriteLine(descriptions[a]);

                  M Offline
                  M Offline
                  max29297
                  wrote on last edited by
                  #8

                  Okay, here's the finished code: using System; using System.Windows.Forms; using System.Drawing; using System.Xml; using System.Collections; class Run : Form {    ArrayList titles;    ArrayList descriptions;    ArrayList images;    int index;        TextBox titleBox;    TextBox descriptionBox;     PictureBox imageBox;    Button nextButton;    Button prevButton;        public Run() {       XmlTextReader reader = new XmlTextReader("file.xml");              index = 0;       titles = new ArrayList();       descriptions = new ArrayList();       images = new ArrayList();              reader.MoveToContent();       while (reader.Read()) {          if (reader.NodeType == XmlNodeType.Element) {             switch (reader.Name) {                case "Title":                   titles.Add(reader.ReadString());                   break;                case "Description":                   descriptions.Add(reader.ReadString());                   break;                case "Image":                   images.Add(reader.ReadString());                   break;             }          } &nbs

                  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