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. I need your suggestion about storing data as XML

I need your suggestion about storing data as XML

Scheduled Pinned Locked Moved XML / XSL
csharpasp-netquestionhtmldata-structures
2 Posts 2 Posters 3 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.
  • L Offline
    L Offline
    lnong
    wrote on last edited by
    #1

    This may be a bit long, but I will try to explain it clearly, so please read on. I'm writing a web-based file management application (in ASP.NET/C#) that requires keeping track of a hierarchy of the names of folders and their files and subfolders (which may include their own files and subfolders). I need to store this whole organizational structure in memory at all times for quick access and modification. This structure will frequently need to be saved to a single file in some format (text, binary or xml) for storage after the application ends. At first, I thought of using ArrayLists (one for folders and one for files). Each would be written as a single object into a binary file for storage. But I realize that it would be rather hard to manage nested folders using an ArrayList. My next attempt is to keep track of the folders using a tree stucture. For instance, the 1st level child nodes will be the 1st level folders, and their children nodes can represent their subfolders, and so on. I need to be using a general tree, not a binary tree because a folder cna have more than 2 subfolders. However, I cannot find a Tree class in .NET anywhere. (There's not even a BinaryTree class). But I did notice that an XML document resembles a general tree structure, which is what I need. My question is that is it possible and efficient for me to store a whole folder hierarchy in XML format? I've never worked with XML documents before, but basically, I want to know if it possible for me to keep track of nested folders like this: (my syntax may be far from correct) <folder name="Main Folder" folderCount="2" fileCount="1"> <folder name="Subfolder 1" folderCount="1" fileCount="0"> <folder name="Subfolder 1a" folderCount="0" fileCount="0"> </folder> </folder> <folder name="Subfolder 2" folderCount="0" fileCount="0"> </folder> <file name="File 1"> </file> </folder> And remember, I need to be able to keep on adding as many levels of nested folders as I want. Am I able to do this with an XML structure? Also, can I dynamically add, remove or modify any folder? MSDN says that ".NET XMLDocument class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document and enables the navigation and editing of this document" If I understand this correctly, it means that this "XML Document" is still an object stored in memory which wil

    N 1 Reply Last reply
    0
    • L lnong

      This may be a bit long, but I will try to explain it clearly, so please read on. I'm writing a web-based file management application (in ASP.NET/C#) that requires keeping track of a hierarchy of the names of folders and their files and subfolders (which may include their own files and subfolders). I need to store this whole organizational structure in memory at all times for quick access and modification. This structure will frequently need to be saved to a single file in some format (text, binary or xml) for storage after the application ends. At first, I thought of using ArrayLists (one for folders and one for files). Each would be written as a single object into a binary file for storage. But I realize that it would be rather hard to manage nested folders using an ArrayList. My next attempt is to keep track of the folders using a tree stucture. For instance, the 1st level child nodes will be the 1st level folders, and their children nodes can represent their subfolders, and so on. I need to be using a general tree, not a binary tree because a folder cna have more than 2 subfolders. However, I cannot find a Tree class in .NET anywhere. (There's not even a BinaryTree class). But I did notice that an XML document resembles a general tree structure, which is what I need. My question is that is it possible and efficient for me to store a whole folder hierarchy in XML format? I've never worked with XML documents before, but basically, I want to know if it possible for me to keep track of nested folders like this: (my syntax may be far from correct) <folder name="Main Folder" folderCount="2" fileCount="1"> <folder name="Subfolder 1" folderCount="1" fileCount="0"> <folder name="Subfolder 1a" folderCount="0" fileCount="0"> </folder> </folder> <folder name="Subfolder 2" folderCount="0" fileCount="0"> </folder> <file name="File 1"> </file> </folder> And remember, I need to be able to keep on adding as many levels of nested folders as I want. Am I able to do this with an XML structure? Also, can I dynamically add, remove or modify any folder? MSDN says that ".NET XMLDocument class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document and enables the navigation and editing of this document" If I understand this correctly, it means that this "XML Document" is still an object stored in memory which wil

      N Offline
      N Offline
      Nitron
      wrote on last edited by
      #2

      I would store your data within a class using std::vector to dynamically allocate your "branches" within the program. Then you can create a class using iostreams to write the data to a file in XML format. Then use something like PugXML (somewhere here on CP, I'm too lazy to look) to get the data back. - Nitron


      "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

      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