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 6922167
In Process

The Archive Base Latest Questions

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

I am working on a Window Phone app were I need to use xpath

  • 0

I am working on a Window Phone app were I need to use xpath with linq. Unfortunately xpath is not currently supported. I have an xml file that I recursively drill down as the user select nodes. The node()/@title is loaded into a listbox. The user selects and so-on. I normally would dynamically build the xpath predicates.

For example:

<cfr>
<chapter title="CHAPTER VI" volume="6">
    <subchapter title="SUBCHAPTER A" volume="6">
        <part number="600" title="PART 600">
            <subpart number="Subpart A" part="PART 600" title="Subpart A Farm Credit Administration">
                <section number="600.1" title="The Farm Credit Act." part="PART 600" link="12CFR600.1" type="cfr"/>
                <section number="600.2" title="Farm Credit Administration." part="PART 600" link="12CFR600.2" type="cfr"/>
            </subpart>
        </part>
        <part number="601" title="PART 601">
            <section number="601.1" title="The Credit Act." part="PART 601" link="12CFR6001.1" type="cfr"/>
        </part>
    </subchapter>
    <part>......</part>
</chapter>
</cfr>   

In xpath I would use:

/node()/node()/node()/node()[@title='PART 601']/node()[@title='The Music Act.']/@title

I keep track of how deep the user has clicked and which index. I would build the xpath predicate like so in c#:

 private String XpathBuilder(bool isParentNode)
    {
        int nCount = AcmSinglton.NodeCount;
        StringBuilder nodeStr = new StringBuilder();
        nodeStr.Append("/node()/node()");

        for (int i = 0; i < nCount; i++)
        {
            if (i != 0)
            {
                nodeStr.Append("[@title = '" + AcmSinglton.TitlePredicatesArrayList.get(i - 1).toString() + "']/node()");
            }
            else
            {
                nodeStr.Append("/node()");
            }
        }
        return nodeStr.ToString();
    }

So I am looking for idea to dynamically build predicates using linq-to-xml.

Here is what I have so far:

 XDocument xml = XDocument.Load(String.Format("Resourses/c{0}x{1}.xml", this.CFRTitle, this.Volume));               
            var nodes = from x in xml.Elements().ElementAt(nodeDepth).Elements()
                        select new Menus.Chapter
                        {
                           Title = x.Attribute("title").Value
                        };

            this.MainListBox.ItemsSource = nodes.ToList();
  • 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-27T10:22:17+00:00Added an answer on May 27, 2026 at 10:22 am

    Something like this should work:

    var currentLevelElements = doc.Root.Elements();
    int depth = 0;
    while (currentLevelElements != null && depth < nodeDepth)
    {
        currentLevelElements = currentLevelElements.Elements()
                                                   .Where( x=> (string) x.Attribute("title") == AcmSinglton.GetTitle(depth));
        depth++;
    }
    var nodes = from x in currentLevelElements select new Menus.Chapter
                        {
                           Title = x.Attribute("title").Value
                        };
    

    It seems awkward to query a Singleton for the title information – this is a dependency that should be passed into your method directly.

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

Sidebar

Related Questions

I'm working on a Cocoa Mac app where I need to display a window/view
I'm working in window phone. I have to bind data in to grid in
I am .NET developer and currently working on App to develop on Windows Phone
I am working on a Windows Phone 7 app and I want to give
When working with window handles, is it good enough to use the plain IntPtr
I have the follwing code (which is not working): private void Window_PreviewKeyDown(object sender, KeyEventArgs
Window.open javascript function is not working in Mozilla, but working in other browsers, here
I am working on an app whose main window has an NSDrawer. It is
I'm in lean startup mode, working on a simple phone app that will be
In my windows phone 7 App I have a single line textbox. When the

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.