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. XML / XSL
  4. How to do curd operations on XML Which Shown Below

How to do curd operations on XML Which Shown Below

Scheduled Pinned Locked Moved XML / XSL
xmltutorial
4 Posts 3 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.
  • R Offline
    R Offline
    Rambabu Sapa
    wrote on last edited by
    #1

    <Messages>
    <category Name="Main">
    <message id="1" title="one" name="Name1" Description="Description1">
    </message>
    </category>
    <category Name="Main1">
    <message id="2" title="two" name="Name2" Description="Description2">
    </message>
    </category>

    L R J 3 Replies Last reply
    0
    • R Rambabu Sapa

      <Messages>
      <category Name="Main">
      <message id="1" title="one" name="Name1" Description="Description1">
      </message>
      </category>
      <category Name="Main1">
      <message id="2" title="two" name="Name2" Description="Description2">
      </message>
      </category>

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

      Do you mean http://en.wikipedia.org/wiki/Create,_read,_update_and_delete[^]?

      Use the best guess

      1 Reply Last reply
      0
      • R Rambabu Sapa

        <Messages>
        <category Name="Main">
        <message id="1" title="one" name="Name1" Description="Description1">
        </message>
        </category>
        <category Name="Main1">
        <message id="2" title="two" name="Name2" Description="Description2">
        </message>
        </category>

        R Offline
        R Offline
        Rambabu Sapa
        wrote on last edited by
        #3

        public static string filePath = HttpContext.Current.Server.MapPath("~/App_Data/Messages.xml");
        public static XmlDocument xmlDoc = new XmlDocument();

        XmlNode _xmlNode = xmlDoc.CreateElement("category"); XmlAttribute _xmlCategoryName = xmlDoc.CreateAttribute("Name"); _xmlCategoryName.Value = categoryName; _xmlNode.Attributes.Append(_xmlCategoryName); // Add Message Node XmlElement _xmlElement = xmlDoc.CreateElement("message"); XmlAttribute _xmlId = xmlDoc.CreateAttribute("id"); _xmlId.Value = Convert.ToString(ID); _xmlElement.Attributes.Append(_xmlId); XmlAttribute _xmltitle = xmlDoc.CreateAttribute("title"); _xmltitle.Value = Convert.ToString(title); _xmlElement.Attributes.Append(_xmltitle); XmlAttribute _xmlname = xmlDoc.CreateAttribute("name"); _xmlname.Value = Convert.ToString(name); _xmlElement.Attributes.Append(_xmlname); XmlAttribute _xmlDescription = xmlDoc.CreateAttribute("Description"); _xmlDescription.Value = Convert.ToString(description); _xmlElement.Attributes.Append(_xmlDescription); _xmlNode.AppendChild(_xmlElement); xmlDoc.DocumentElement.AppendChild(_xmlNode);

        1 Reply Last reply
        0
        • R Rambabu Sapa

          <Messages>
          <category Name="Main">
          <message id="1" title="one" name="Name1" Description="Description1">
          </message>
          </category>
          <category Name="Main1">
          <message id="2" title="two" name="Name2" Description="Description2">
          </message>
          </category>

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

          This is not the document you want for figuring out CRUD. You need the XSD to do that properly. You could guess and as long as the database column names matched you *might* be able to guess correctly, but...I would not be helping you if I recommended that you do that. If you can write your own query to select a row and if you also had access to ADO.NET -- you could have the table tell you its schema and then the query could be written properly. This method that you are using -- is not a great idea -- you can have some success in doing it, but not for long and it is very likely that you will manage to put a row in the database that will be junk data because you do not know the schema -- you are just making blind CRUD operations. A better choice might be stored procedures because you can just provide the parameters from the client side. At any rate, the less you count on being smart on the client side, the better off you will be.

          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