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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:39:50+00:00 2026-06-11T09:39:50+00:00

I am trying to parse TOC.ncx (which is xml) in WP7 C# Following is

  • 0

I am trying to parse TOC.ncx (which is xml) in WP7 C#

Following is the content of file:

<navMap>
<navPoint id="navpoint-1" playOrder="1"><navLabel><text>Cover</text></navLabel><content src="xhtml/cover.html" /></navPoint>
<navPoint id="navpoint-2" playOrder="2"><navLabel><text>Title Page</text></navLabel><content src="xhtml/title.html" /></navPoint>
<navPoint id="navpoint-3" playOrder="3"><navLabel><text>Contents</text></navLabel><content src="xhtml/toc.html" /></navPoint>
<navPoint id="navpoint-4" playOrder="4"><navLabel><text>Foreword</text></navLabel><content src="xhtml/foreword.html" /></navPoint>
<navPoint id="navpoint-5" playOrder="5"><navLabel><text>Preface</text></navLabel><content src="xhtml/preface.html" /></navPoint>
<navPoint id="navpoint-6" playOrder="6"><navLabel><text>Introduction</text></navLabel><content src="xhtml/introduction.html" /></navPoint>
<navPoint id="navpoint-7" playOrder="7"><navLabel><text>The East India Company</text></navLabel><content src="xhtml/chapter001.html" />
    <navPoint id="navpoint-8" playOrder="8"><navLabel><text>The Voyages</text></navLabel><content src="xhtml/chapter001.html#eas0000222" /></navPoint>
    <navPoint id="navpoint-9" playOrder="9"><navLabel><text>Mission to India</text></navLabel><content src="xhtml/chapter002.html" /></navPoint>
    <navPoint id="navpoint-10" playOrder="10"><navLabel><text>Madras, Bombay and Calcutta</text></navLabel><content src="xhtml/chapter003.html" /></navPoint>
    <navPoint id="navpoint-11" playOrder="11"><navLabel><text>Growth Amidst Turmoil</text></navLabel><content src="xhtml/chapter004.html" /></navPoint>
    <navPoint id="navpoint-12" playOrder="12"><navLabel><text>A Bridge between Many Worlds</text></navLabel><content src="xhtml/chapter005.html" /></navPoint>
    <navPoint id="navpoint-13" playOrder="13"><navLabel><text>Partners and Agents</text></navLabel><content src="xhtml/chapter006.html" /></navPoint>
    <navPoint id="navpoint-14" playOrder="14"><navLabel><text>War and Plunder</text></navLabel><content src="xhtml/chapter007.html" /></navPoint>
    <navPoint id="navpoint-15" playOrder="15"><navLabel><text>Ruler in India</text></navLabel><content src="xhtml/chapter008.html" /></navPoint>
    <navPoint id="navpoint-16" playOrder="16"><navLabel><text>The Company and Indian History</text></navLabel><content src="xhtml/chapter009.html" /></navPoint>
</navPoint>
<navPoint id="navpoint-17" playOrder="17"><navLabel><text>Timeline</text></navLabel><content src="xhtml/appendix001.html" /></navPoint>
<navPoint id="navpoint-18" playOrder="18"><navLabel><text>Bibliography</text></navLabel><content src="xhtml/appendix002.html" /></navPoint>
<navPoint id="navpoint-19" playOrder="19"><navLabel><text>Copyright Page</text></navLabel><content src="xhtml/copyright.html" /></navPoint>
</navMap>

And following is the code I have written to get the navPoint:

private List<NavPoint> GetNavigationChildren(IEnumerable<XElement> elements, XNamespace nameSpace)
        {
            List<NavPoint> navigationPoints = new List<NavPoint>(elements.Count());
            if (!elements.Any())
                return navigationPoints;

            navigationPoints.AddRange(elements.Select(navPoint =>
                new NavPoint(navPoint.Attribute("id").Value,
                            navPoint.Element(nameSpace + "navLabel").Element(nameSpace + "text").Value,
                            HttpUtility.UrlDecode(navPoint.Element(nameSpace + "content").Attribute("src").Value),
                            int.Parse(navPoint.Attribute("playOrder").Value), Content[0] as EpubContent,
                            GetNavigationChildren(navPoint.Elements(nameSpace + "navPoint"),
                            nameSpace))));

            return navigationPoints;
        }

By executing above code, I am able to get the top level nav points(i.e. navPoint-1 to navPoint-7 and then navPoint-17 to navPoint-19) but the problem is its not getting the child elements i.e. navPoints of navPoint-7.

Can anyone suggest what wrong I am doing here??

Calling of the GetNavigationChildren is done as:

XElement xElement = XElement.Parse(@xmlText);
XNamespace xNamespace = xElement.Attribute("xmlns") != null ? xElement.Attribute("xmlns").Value : XNamespace.None;
List<NavPoint> navPoints = GetNavigationChildren(xElement.Element(xNamespace + "navMap").Elements(xNamespace + "navPoint"), xNamespace);

And the class def of NavPoint is:

public NavPoint(string id, string title, string source, int order, EpubContent contentData, List<NavPoint> children)
        {
            ID = id;
            Title = title;
            Source = source;
            Order = order;
            ContentData = contentData;
            Children = children;
        }

Please help!

  • 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-06-11T09:39:51+00:00Added an answer on June 11, 2026 at 9:39 am

    If you need a flat list of NavPoints, you need to use Descendants instead of Elements.

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

Sidebar

Related Questions

I am trying to parse specific XML file which is located in sub directories
Trying to parse xml to text I got something like this, INPUT FILE <Item
Trying to parse the following Python file using the lxml.etree.iterparse function. sampleoutput.xml <item> <title>Item
I'm trying parse the follow XML file: <root>Root <pai>Pai_1 <filho>Pai1,Filho1</filho> <filho>Pai1,Filho2</filho> </pai> <pai>Pai_2 <filho>Pai2,Filho1</filho>
I have an xml feed at this url Now im trying parse the content,
I am trying parse out some text that is in an html file. The
Trying to parse out this xml file to get a list of Elements but
While trying to parse an xml file into table format, jQuery keeps closing my
When trying to parse the following file, I get the error [10,4]: [ERR 101]
Trying to parse an HTML document and extract some elements (any links to text

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.