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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. C# XML Atribute help? [modified]

C# XML Atribute help? [modified]

Scheduled Pinned Locked Moved C#
helpcsharpxmlquestion
6 Posts 4 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.
  • N Offline
    N Offline
    Nematjon Rahmanov
    wrote on last edited by
    #1

    Hi . I have xml file .

    XmlWriter writer = XmlWriter.Create(path + "\\playbackmanu.xml");
    writer.WriteStartDocument();
    writer.WriteStartElement("PlayBack");

    for(int i=1;i<=nCount;i++)
    {
    writer.WriteStartElement("ItemInfo");
    writer.WriteElementString("itemimgpath","img"+ i.ToString() + ".jpg");
    writer.WriteElementString("itemname", "");
    writer.WriteElementString("itemtitle", "Title "+i.ToString());
    writer.WriteElementString("itemcommand",i.ToString());
    writer.WriteEndElement();
    }

    writer.WriteEndElement();
    writer.WriteEndDocument();
    writer.Close();


    #PlayBack#
    #ItemInfo#
    #itemimgpath#img1.jpg#/itemimgpath#
    #itemname##/itemname#
    #itemtitle#Title 1#/itemtitle#
    #itemcommand#1#/itemcommand#
    #/ItemInfo#

    #ItemInfo#
    	#itemimgpath#img2.jpg#/itemimgpath#
    	#itemname##/itemname#
    	#itemtitle#Title 2#/itemtitle#
    	#itemcommand#2#/itemcommand#
    #/ItemInfo#
    

    #/PlayBack#

    is < and >


    How i can add atribute first node ? #PlayBack testAtribute="Hello world"# Thanks.

    We are haven't bug,just temporarily undecided problems.

    modified on Wednesday, April 14, 2010 6:24 AM

    E J N L 4 Replies Last reply
    0
    • N Nematjon Rahmanov

      Hi . I have xml file .

      XmlWriter writer = XmlWriter.Create(path + "\\playbackmanu.xml");
      writer.WriteStartDocument();
      writer.WriteStartElement("PlayBack");

      for(int i=1;i<=nCount;i++)
      {
      writer.WriteStartElement("ItemInfo");
      writer.WriteElementString("itemimgpath","img"+ i.ToString() + ".jpg");
      writer.WriteElementString("itemname", "");
      writer.WriteElementString("itemtitle", "Title "+i.ToString());
      writer.WriteElementString("itemcommand",i.ToString());
      writer.WriteEndElement();
      }

      writer.WriteEndElement();
      writer.WriteEndDocument();
      writer.Close();


      #PlayBack#
      #ItemInfo#
      #itemimgpath#img1.jpg#/itemimgpath#
      #itemname##/itemname#
      #itemtitle#Title 1#/itemtitle#
      #itemcommand#1#/itemcommand#
      #/ItemInfo#

      #ItemInfo#
      	#itemimgpath#img2.jpg#/itemimgpath#
      	#itemname##/itemname#
      	#itemtitle#Title 2#/itemtitle#
      	#itemcommand#2#/itemcommand#
      #/ItemInfo#
      

      #/PlayBack#

      is < and >


      How i can add atribute first node ? #PlayBack testAtribute="Hello world"# Thanks.

      We are haven't bug,just temporarily undecided problems.

      modified on Wednesday, April 14, 2010 6:24 AM

      E Offline
      E Offline
      Estys
      wrote on last edited by
      #2

      Just after writer.WriteStartElement("PlayBack");

      writer.WriteAttributeString("testAtribute", "Hello world");

      Good luck

      1 Reply Last reply
      0
      • N Nematjon Rahmanov

        Hi . I have xml file .

        XmlWriter writer = XmlWriter.Create(path + "\\playbackmanu.xml");
        writer.WriteStartDocument();
        writer.WriteStartElement("PlayBack");

        for(int i=1;i<=nCount;i++)
        {
        writer.WriteStartElement("ItemInfo");
        writer.WriteElementString("itemimgpath","img"+ i.ToString() + ".jpg");
        writer.WriteElementString("itemname", "");
        writer.WriteElementString("itemtitle", "Title "+i.ToString());
        writer.WriteElementString("itemcommand",i.ToString());
        writer.WriteEndElement();
        }

        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Close();


        #PlayBack#
        #ItemInfo#
        #itemimgpath#img1.jpg#/itemimgpath#
        #itemname##/itemname#
        #itemtitle#Title 1#/itemtitle#
        #itemcommand#1#/itemcommand#
        #/ItemInfo#

        #ItemInfo#
        	#itemimgpath#img2.jpg#/itemimgpath#
        	#itemname##/itemname#
        	#itemtitle#Title 2#/itemtitle#
        	#itemcommand#2#/itemcommand#
        #/ItemInfo#
        

        #/PlayBack#

        is < and >


        How i can add atribute first node ? #PlayBack testAtribute="Hello world"# Thanks.

        We are haven't bug,just temporarily undecided problems.

        modified on Wednesday, April 14, 2010 6:24 AM

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        Did reading the documentation for XmlWriter not strike you as an idea? http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.writeattributes.aspx[^] edit: This one is probably a better link[^]

        1 Reply Last reply
        0
        • N Nematjon Rahmanov

          Hi . I have xml file .

          XmlWriter writer = XmlWriter.Create(path + "\\playbackmanu.xml");
          writer.WriteStartDocument();
          writer.WriteStartElement("PlayBack");

          for(int i=1;i<=nCount;i++)
          {
          writer.WriteStartElement("ItemInfo");
          writer.WriteElementString("itemimgpath","img"+ i.ToString() + ".jpg");
          writer.WriteElementString("itemname", "");
          writer.WriteElementString("itemtitle", "Title "+i.ToString());
          writer.WriteElementString("itemcommand",i.ToString());
          writer.WriteEndElement();
          }

          writer.WriteEndElement();
          writer.WriteEndDocument();
          writer.Close();


          #PlayBack#
          #ItemInfo#
          #itemimgpath#img1.jpg#/itemimgpath#
          #itemname##/itemname#
          #itemtitle#Title 1#/itemtitle#
          #itemcommand#1#/itemcommand#
          #/ItemInfo#

          #ItemInfo#
          	#itemimgpath#img2.jpg#/itemimgpath#
          	#itemname##/itemname#
          	#itemtitle#Title 2#/itemtitle#
          	#itemcommand#2#/itemcommand#
          #/ItemInfo#
          

          #/PlayBack#

          is < and >


          How i can add atribute first node ? #PlayBack testAtribute="Hello world"# Thanks.

          We are haven't bug,just temporarily undecided problems.

          modified on Wednesday, April 14, 2010 6:24 AM

          N Offline
          N Offline
          Nematjon Rahmanov
          wrote on last edited by
          #4

          :rose::rose:

          We are haven't bug,just temporarily undecided problems.

          E 1 Reply Last reply
          0
          • N Nematjon Rahmanov

            :rose::rose:

            We are haven't bug,just temporarily undecided problems.

            E Offline
            E Offline
            Estys
            wrote on last edited by
            #5

            Thanks

            Nematjon Rahmanov wrote:

            We are haven't bug,just temporarily undecided problems It's not a bug, it's a feature!!!

            FTFY

            I hate signatures, but I love 5's

            1 Reply Last reply
            0
            • N Nematjon Rahmanov

              Hi . I have xml file .

              XmlWriter writer = XmlWriter.Create(path + "\\playbackmanu.xml");
              writer.WriteStartDocument();
              writer.WriteStartElement("PlayBack");

              for(int i=1;i<=nCount;i++)
              {
              writer.WriteStartElement("ItemInfo");
              writer.WriteElementString("itemimgpath","img"+ i.ToString() + ".jpg");
              writer.WriteElementString("itemname", "");
              writer.WriteElementString("itemtitle", "Title "+i.ToString());
              writer.WriteElementString("itemcommand",i.ToString());
              writer.WriteEndElement();
              }

              writer.WriteEndElement();
              writer.WriteEndDocument();
              writer.Close();


              #PlayBack#
              #ItemInfo#
              #itemimgpath#img1.jpg#/itemimgpath#
              #itemname##/itemname#
              #itemtitle#Title 1#/itemtitle#
              #itemcommand#1#/itemcommand#
              #/ItemInfo#

              #ItemInfo#
              	#itemimgpath#img2.jpg#/itemimgpath#
              	#itemname##/itemname#
              	#itemtitle#Title 2#/itemtitle#
              	#itemcommand#2#/itemcommand#
              #/ItemInfo#
              

              #/PlayBack#

              is < and >


              How i can add atribute first node ? #PlayBack testAtribute="Hello world"# Thanks.

              We are haven't bug,just temporarily undecided problems.

              modified on Wednesday, April 14, 2010 6:24 AM

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              FYI you can use < (<) and > (>) in your posts instead of # That would make it a bit clearer IMO

              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