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. Delphi
  4. Load XML string in to TTreeView

Load XML string in to TTreeView

Scheduled Pinned Locked Moved Delphi
xmlhelp
3 Posts 2 Posters 6 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
    NJdotnetdev
    wrote on last edited by
    #1

    I have GUI control TTreeView. My goal is populate the TTreeNodes after reading xml from the file system. My XML looks like:

    <1 id="child">
    <2 id="child">

    Note: There could be more levels of parent and child nesting. I did search internet but nothing strike my mind as a straight forward answer. Would appreciate any help I can get.

    D 1 Reply Last reply
    0
    • N NJdotnetdev

      I have GUI control TTreeView. My goal is populate the TTreeNodes after reading xml from the file system. My XML looks like:

      <1 id="child">
      <2 id="child">

      Note: There could be more levels of parent and child nesting. I did search internet but nothing strike my mind as a straight forward answer. Would appreciate any help I can get.

      D Offline
      D Offline
      DeerBear
      wrote on last edited by
      #2

      Hi!

      procedure LoadDocument( ADocument : IXMLDocument;ATreeview : TTreeView );

      procedure AddXMLNode( AXmlNode : IXMLNode;AParent : TTreeNode );
      var tvNode : TTreViewNode;
      ChildIndex : Integer;
      begin
      tvNode := ATreeView.Items.Add( AParent,'' );
      // your tvNode stuff goes here
      if AXMLNode.ChildrenCount > 0 Then
      begin
      for ChildIndex := 0 to AXMLNode.ChildrenCount - 1 do
      begin
      AddXMLNode( AXMLNode.Children [ ChildIndex ],tvNode );
      end;
      end;
      end;
      begin
      AddXMLNode( AXMLDocument.RootNode, nil );
      end;

      Adjust and fix compiler errors. A

      N 1 Reply Last reply
      0
      • D DeerBear

        Hi!

        procedure LoadDocument( ADocument : IXMLDocument;ATreeview : TTreeView );

        procedure AddXMLNode( AXmlNode : IXMLNode;AParent : TTreeNode );
        var tvNode : TTreViewNode;
        ChildIndex : Integer;
        begin
        tvNode := ATreeView.Items.Add( AParent,'' );
        // your tvNode stuff goes here
        if AXMLNode.ChildrenCount > 0 Then
        begin
        for ChildIndex := 0 to AXMLNode.ChildrenCount - 1 do
        begin
        AddXMLNode( AXMLNode.Children [ ChildIndex ],tvNode );
        end;
        end;
        end;
        begin
        AddXMLNode( AXMLDocument.RootNode, nil );
        end;

        Adjust and fix compiler errors. A

        N Offline
        N Offline
        NJdotnetdev
        wrote on last edited by
        #3

        Thanks a lot for the help.

        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