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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:40:08+00:00 2026-05-23T09:40:08+00:00

I have the following xml which I parse using jquery. However I’m stuck at

  • 0

I have the following xml which I parse using jquery.

However I’m stuck at displaying only the cities and dates grouped by the title.
How can I parse the xml so that the final output would be like this

Test event 1 – oslo(2011/08/11), dallas(2011/11/11)

Test event 2 – new york(…), seattle(…)

Any Help would be appreciated,

Thanks,
Terry

<root>
    <item guid="np_108886">
        <title>Test event 1</title>
        <description>lorem ipsum</description>
        <specfields>
            <city>oslo</city>
            <startdate>2011/08/11</startdate>
        </specfields>
    </item>

    <item guid="np_108886">
        <title>Test event 1</title>
        <description>lorem ipsum</description>
        <specfields>
            <city>dallas</city>
            <startdate>2011/11/11</startdate>
        </specfields>
    </item>

    <item guid="np_108886">
        <title>Test event 2</title>
        <description>lorem ipsum</description>
        <specfields>
            <city>new york</city>
            <startdate>2011/09/11</startdate>
        </specfields>
    </item>
    <item guid="np_108886">
        <title>Test event 2</title>
        <description>lorem ipsum</description>
        <specfields>
            <city>seattle</city>
            <startdate>2011/09/11</startdate>
        </specfields>
    </item>
</root>
  • 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-23T09:40:09+00:00Added an answer on May 23, 2026 at 9:40 am

    http://jsfiddle.net/XnmNU/6/ – working jFiddle {edit child selectors!}

    My version compares the previouse title against the current to decern if its a dupe or not, sorry i do not have time to absolutly optimise the code i am at work 🙁

    outputs>
    Start
    Test event 1 — oslo (2011/08/11)
    dallas (2011/11/11)
    Test event 2 — new york (2011/09/11)
    seattle (2011/09/11)

    $("document").ready(function(){
        var xml = "<root>     <item guid='np_108886'>         <title>Test event 1</title>         <description>lorem ipsum</description>         <specfields>             <city>oslo</city>             <startdate>2011/08/11</startdate>         </specfields>     </item>      <item guid='np_108886'>         <title>Test event 1</title>         <description>lorem ipsum</description>         <specfields>             <city>dallas</city>             <startdate>2011/11/11</startdate>         </specfields>     </item>      <item guid='np_108886'>         <title>Test event 2</title>         <description>lorem ipsum</description>         <specfields>             <city>new york</city>             <startdate>2011/09/11</startdate>         </specfields>     </item>     <item guid='np_108886'>         <title>Test event 2</title>         <description>lorem ipsum</description>         <specfields>             <city>seattle</city>             <startdate>2011/09/11</startdate>         </specfields>     </item> </root>",     xmlDoc = $.parseXML( xml ); xml = $(xmlDoc);
    
        try
      {
      $(xml).find('[nodeName=item]').each(function(){    if ($(this).index() != 0) {
          possitionTitle = $(this).prev();
         if ($(this).children('title').text() != possitionTitle.children('title').text() ) {
                    $("div").append("</li><li>"+$(this).children('title').text()+" -- "+$(this).children("specfields").children("city").text()+" ("+$(this).children("specfields").children("startdate").text()+")");
                    } else {
                        $("div").append($(this).children("specfields").children("city").text()+" ("+$(this).children("specfields").children("startdate").text()+")");
                    }
            } else {
                $("div").append("Start<li>"+$(this).children('title').text()+" -- "+$(this).children("specfields").children("city").text()+" ("+$(this).children("specfields").children("startdate").text()+")");
            }
            $("div").append("</li>");
    
        });
    
      }
    catch(err)
      {
      alert(err);
      }
    
    });
    <div></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery to parse XML which is retrieved via ajax, however I have
I have a class which loads an xml file using the following: Path.Combine( AppDomain.CurrentDomain.BaseDirectory,
I have the following node I need to parse using XSLT 1.0 from xml
I'm trying to parse xml from SharePoint service (lists) using jquery. I have XMLHttpRequest
I have a client that sends an xml feed which I parse using the
I have an xml document which consists of a number of the following: -
I have an XML document which contains nodes like following:- <a class=custom>test</a> <a class=xyz></a>
I have a large XML file which in the middle contains the following: <ArticleName>Article
I have the following snippet in my pom.xml (Full pom attached below which can
I have the following output (via link) which displays the var_dump of some XML

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.