开发者

C# How to i store website list in xmlnode

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 w开发者_Python百科hat are the node or element and how to maintain proper hierarchy.


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


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,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜