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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:09:54+00:00 2026-05-27T13:09:54+00:00

Im using YQL to get some data and here is my xml: <?xml version=1.0

  • 0

Im using YQL to get some data and here is my xml:

<?xml version="1.0" encoding="UTF-8"?>
<div id="content>
<div id="html">
<h3>City</h3>
<div id="movie">
    <h4>
        <a href="">movie 1</a>
    </h4>
<div>
<div id="movie>
    <h4>
        <a href="">movie 2</a>
    </h4>
</div>
    .
    .
    .

<h3>City 2</h3>
<div id="movie">
    <h4>
        <a href="">movie 1</a>
    </h4>
<div>
<div id="movie>
    <h4>
        <a href="">movie 2</a>
    </h4>
</div>

I want to populate a listbox in my windows phone app with the city name and its movies like this:

City 1
Movie1
Movie 2

City 2
Movie1
Movie 2

However, I’m getting stuck here since all the XML is inside the div with id content.

How could a make a LINQ statement to solve this?

  • 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-27T13:09:55+00:00Added an answer on May 27, 2026 at 1:09 pm

    I tried to morph your posted input into some well-formed XML:

    <div id="content">
      <div id="html">
        <h3>City</h3>
        <div id="movie">
          <h4>
            <a href="">movie 1</a>
          </h4>
        </div>
        <div id="movie">
          <h4>
            <a href="">movie 2</a>
          </h4>
        </div>
        .
        .
        .
    
        <h3>City 2</h3>
        <div id="movie">
          <h4>
            <a href="">movie 1</a>
          </h4>
        </div>
        <div id="movie">
          <h4>
            <a href="">movie 2</a>
          </h4>
        </div>
      </div>
    </div>
    

    Then you can get a List with the code

        XDocument doc = XDocument.Load("input.xml");
        List<string> data =
            doc.Descendants("h3")
            .Union(
              doc.Descendants("div")
              .Where(d => (string)d.Attribute("id") == "movie")
              .Elements("h4")
              .Elements("a")
              ).InDocumentOrder()
            .Select(e => e.Value)
            .ToList();
    

    [edit] Your initial request seemed to ask for a flat list result, your comment suggests you rather want a grouped structure so here is an adapted sample:

        XDocument doc = XDocument.Load("input.xml");
        var groupedData =
            (from movie in doc.Root.Descendants("div")
             where (string)movie.Attribute("id") == "movie"
             group movie by movie.ElementsBeforeSelf("h3").Last() into g
             select new
             {
                 city = g.Key.Value,
                 movies = (from m in g
                           select (string)m.Element("h4").Element("a")).ToList()
             }).ToList();
    
        // now use above list for data binding or 
        // in the simplest case just consume it with foreach:
        foreach (var group in groupedData)
        {
            Console.WriteLine("city: {0}:", group.city);
            foreach (var movie in group.movies)
            {
                Console.WriteLine(movie);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem here. I am using YQL & jQuery to get some
I'm trying to load some external content using jQuery load function to div on
Currently, I can get stock quote by returning xml and json using YQL console
Hey, I'd like to scrape some data from my blog using YQL: SELECT *
i am trying to get access to whitepages using YQL. Unfortunately i don't have
I'm using ruby and googles reverse geocode yql table to ideally automate some search
I am currently using geolocation to get the user's country name. Here is my
I'm using YQL to parse some web feeds, this one in particular. SELECT *
I am trying to execute some queries using YQL. To gain some efficiency, I
so I'm using YQL to get a youtube user's subscriber count. to do this

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.