-1

I am trying to store website contents in XmlNode. my website structure is

  • Site1

    1. List1

      • Folder1
      • Folder2
        a] file1
        b] file2
      • Folder3
    2. List2

  • Site2
    1. List1
    2. List2
  • Site3 ...............
  • Site4 .........................

So how do i store it in XMLNode. my method should return whole structure as an node not as document. Thanks in advance.
EDIT: In above case what are the node or element and how to maintain proper hierarchy.

Royson
  • 2,851
  • 13
  • 36
  • 50

2 Answers2

0

can you be more specific waht is the problem if the problem parsing the html or creating the XMLNod. Here is A link that shows creating xml by code ti creates XMLDocument but you can use just tha part that creates the root XMLNode

http://www.java2s.com/Code/CSharp/XML/ProgrammaticallycreatinganewXMLdocument.htm

About parsing th html look at this link

Looking for C# HTML parser

Community
  • 1
  • 1
IordanTanev
  • 6,130
  • 5
  • 40
  • 49
0

Sounds to me you would like to waLk the ´object model´ (your site structure) and build an XML document with this structure.

A recursive function would be an option (pseudo code):


BuildRecursiveStructure(SiteStructureNode currentSiteNode, XmlNode buildNode)
{
        newNode = xDoc.CreateElement( currentSiteNode.name );
    buildNode.addChild( newNode );
        foreach (?? childSiteNode in currentSiteNode.Children)
    {
        BuildRecursiveStructure( childSiteNode, newNode );
    }
}

XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml("");

BuildRecursiveStrucure( SitesInfoRoot? , xDoc.DocumentElement);

Hope this helps,

Marvin Smit
  • 4,088
  • 1
  • 22
  • 21