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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:22:33+00:00 2026-06-06T17:22:33+00:00

the xml <publication_date media_type=print> <month>1</month> <year>2011</year> </publication_date> I have used this code to get

  • 0

the xml

<publication_date media_type="print">
        <month>1</month>
        <year>2011</year>
</publication_date>

I have used this code to get title

var year = $xml.find('publication_date year').text();

but sometimes the xml contains two different types like this:

<publication_date media_type="print">
        <month>05</month>
        <day>22</day>
        <year>2012</year>
</publication_date>
<publication_date media_type="online">
        <month>04</month>
        <day>26</day>
        <year>2012</year>
</publication_date>

I want to select the year witch comes with online media-type and if there is no online select print type.

  • 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-06T17:22:36+00:00Added an answer on June 6, 2026 at 5:22 pm

    That’s simple, use an attribute selector:

    $xml.find("publication_date[media_type=online] year").text()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this document where i want to get to the value in x_server_response/retrieve_resources_by_category_response/source_full_info/record/
XML Code: <GridLayout android:id=@+id/grid android:layout_width=fill_parent android:layout_height=fill_parent android:layout_above=@+id/step android:layout_alignParentLeft=true android:layout_alignParentRight=true android:layout_below=@+id/menu > </GridLayout> The above
XML: <A><B></B></A> or <A></A> I want to get all A nodes that do not
I am trying and trying to parse an XML document. I can get all
I have got the XML below, which is stored in string type variable, and
XML element I am accessing: is here, if below sample is unreadable: http://api.petfinder.com/pet.find?&animal=dog&count=150&location=90605&key=a94884c2349b5b6975ec84fb51ac3ec4 <pets>
This is my XML snippet (it has a root element). <ItemAttributes> <Author>Ellen Galinsky</Author> <Binding>Paperback</Binding>
I have a small application that searches publication citations. The citations are in XML
Upgrading .Net Events system from Tridion 2009 to Tridion 2011 SP1. Does anyone have
I can't get the link tag to come through when I'm parsing XML. I've

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.