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

  • Home
  • SEARCH
  • 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 5844191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:15:27+00:00 2026-05-22T12:15:27+00:00

I am working on a genealogy application and I plan to store references to

  • 0

I am working on a genealogy application and I plan to store references to each family member in an XML document. I would like to read this document and display it as a treeview in my application and then use it to display a family member elsewhere in the application. What I need to do is find a specific value in the node tree (each member will have a unique value). How would I find this value? Could you please give me a hand here, I am quite new to node editing. TY.

BTW, below is my XAML code:

        <HierarchicalDataTemplate x:Key="NodeTemplate">
        <HierarchicalDataTemplate.ItemsSource>
            <Binding XPath="child::*" />
        </HierarchicalDataTemplate.ItemsSource>
        <TextBlock Text="{Binding Path=Name}" />
    </HierarchicalDataTemplate>
    <XmlDataProvider x:Key="xmlDataProvider"></XmlDataProvider>
</Window.Resources>
<Grid>
    <TreeView Margin="0,24,0,143"
              Name="treeView1"
              Background="AliceBlue"
              ItemsSource="{Binding Source={StaticResource xmlDataProvider}, XPath=*}"
              ItemTemplate= "{StaticResource NodeTemplate}"/>
  • 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-22T12:15:28+00:00Added an answer on May 22, 2026 at 12:15 pm

    I’ve assumed that the unique value is the id attribute. So the code will look so:

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var item = FindItemById(treeView1.Items.Cast<XmlElement>(), "2.1");
            if (item != null)
            {
                //Do something...
                //for example, item.SetAttribute("name", "test");
    
                //But this code will not work if the item isn't visible
                //var container = treeView1.ItemContainerGenerator.ContainerFromItem(item);
            }
        }
    
        public XmlElement FindItemById(IEnumerable<XmlElement> items, string id)
        {
            foreach (var item in items)
            {
                if (item.HasAttribute("id") && item.GetAttribute("id") == id)
                    return item;
                var childItemsResult = FindItemById(item.ChildNodes.Cast<XmlElement>(), id);
                if (childItemsResult != null)
                    return childItemsResult;
            }
    
            return null;      
        }
    

    If your xml file has a different attribute as an identifier, change this line accordingly: item.HasAttribute("id") && item.GetAttribute("id").

    The final result will be the XmlElement object. But it isn’t easy to retrieve the container because of the algorithm of generation of treeview items. Anyway, if you have a specific question – I can help to build a correct architecture.

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

Sidebar

Related Questions

Working on a movie website and would love to find an API that I
Working demo CLick $(document).ready(function(e) { $('span#pijlr, span#pijll').show(); $('#gallery').css('overflow','hidden'); $('span#pijlr').click(function(e) { if (!$('#gallcont').is(':animated')) { var
Working with a Lucene index, I have a standard document format that looks something
Working with Json, how can I NSlog only the title in this code: NSDictionary
Working on a project and the coder does this a lot in his checks.
Working on this EF tutorial , I've difficult to understand the meaning of the
Working on a legacy application at the moment and we are replacing the data
Working with an API that can handle multiple connections (i.e. sessions), each of these
Working on THIS Page: newsite.702wedding.com/live/ Can't find where to remove the arrows at the
Working through this for fun: http://www.diku.dk/hjemmesider/ansatte/torbenm/Basics/ Example calculation of nullable and first uses a

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.