Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7690667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:26:57+00:00 2026-05-31T20:26:57+00:00

I want to browse through XML using a TTreeView. To associate the treeview nodes

  • 0

I want to browse through XML using a TTreeView. To associate the treeview nodes with the XML nodes with attributes I used the following syntax:

var tv: TTreeView; tn1, tn2: TTreeNode; xn: IXMLNode;

if xn.AttributeNodes.Count > 0 then
  tn2 := tv.Items.AddChildObject( tn1, xn.NodeName, @xn )
else
  tn2 := tv.Items.AddChild( tn1, xn.NodeName );

.. and later in the program:

var  tv: TTreeView; pxn: ^IXMLNode; i: integer;

pxn := tv.Selected.Data;
for i := 0 to iXML.AttributeNodes.Count-1 do
  ShowMessage ( pxn^.AttributeNodes[i].LocalName + ' = ' +
                pxn^.AttributeNodes[i].Text );

which results in an exception.. As far as I can figure out this has to do with the fact that I’m point to an interface instead of an object.

Is it possible to reference the actual object of the XML instead of the interface?
What will happen with this reference if new XML nodes are inserted in or deleted from the tree?

Or is there another straight forward solution?

All help appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:26:58+00:00Added an answer on May 31, 2026 at 8:26 pm

    don’t use @ and ^ operators, interfaces are already references

    first code:

    var tv: TTreeView; tn1, tn2: TTreeNode; xn: IXMLNode;
    
    if xn.AttributeNodes.Count > 0 then
      tn2 := tv.Items.AddChildObject( tn1, xn.NodeName, Pointer(xn) )
    else
      tn2 := tv.Items.AddChild( tn1, xn.NodeName );
    

    second code (don’t forget to check if data is assigned)

    var  tv: TTreeView; pxn: IXMLNode; i: integer;
    
    if Assigned(tv.Selected) and Assigned(tv.Selected.Data) then begin
      pxn := IXMLNode(tv.Selected.Data);
      for i := 0 to iXML.AttributeNodes.Count-1 do
        ShowMessage ( pxn.AttributeNodes[i].LocalName + ' = ' +
                      pxn.AttributeNodes[i].Text );
    end;
    

    Just search in the net for more information about interfaces, classes and the differences between them. Good information: http://blog.synopse.info/post/2012/02/29/Delphi-and-interfaces

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to parse an XML file from URL using JDOM. But when trying
Hi i want to browse every 10 records on a click. The AJAX call
I am working with Flex, Flash, Action Script and I want to browse the
I want to change the Text of the browse button in the FileUpload Control
Say you have an app, that you want to provide users ability to browse
I am developing a component in J! 2.5 and want to add a browse
I want to capture the browser window/tab close event. I have tried the following
I need to pre-compress some very large html/xml/json files (large data dumps) using either
I have a web service that I want to access through SOAP. But I
I am trying to browse through the history of a file in SVN and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.