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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:16:59+00:00 2026-06-04T07:16:59+00:00

I found and edited this code to use jquery to display elements of an

  • 0

I found and edited this code to use jquery to display elements of an xml feed from an online calendar on a web page. Is there a way for me to include conditions so that I can display the information from a node when it’s populated and ignore it when the node is empty? For example, to include the imagepath, imagetext and necessary html to format it but disregard all of that when there is no imagepath and imagetext information?

<script>
$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "http://orion.lib.mi.us/evanced/lib/eventsxml.asp?dm=exml&lib=0&nd=90",
        dataType: "xml",
        success: xmlParser,
        error: function(){alert("We're sorry. Something didn't load correctly.");}
    });
});

function xmlParser(xml) {
    $(xml).find("item").each(function () {
        var xml_image       = $(this).find('imagepath').text();
        var xml_imagetext   = $(this).find('imagetext').text();
        var xml_title       = $(this).find('title').text();
        var xml_date        = $(this).find('date').text();
        var xml_time        = $(this).find('time').text();
        var xml_location    = $(this).find('location').text();
        var xml_link        = $(this).find('link').text();
        var xml_description = $(this).find('description').text();
        $(".main").append('<div class="event"><div class="logo"><img alt="' + xml_imagetext + '" src="' + xml_image + '" /></div><p class="title"><a href="' + xml_link + '">' + xml_title + '</a></p><p class="when">' + xml_date + ' at ' + xml_time + '</p><p class="location">Location: ' + xml_location + '</p><p class="description">' + xml_description + '</p><p class="link"><a href="' + xml_link + '">More Information</a></p></div>');
    });}
</script>
  • 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-04T07:17:00+00:00Added an answer on June 4, 2026 at 7:17 am

    You might want to simply add a condition before appending the content to main.

    if (xml_image != "" && xml_imagetext != "") {
        $(".main").append...
    }
    

    Or if you want to display different things, do something along these lines:

    var hasImage = xml_image != "" && xml_imagetext != "";
    var html = "<div class='event'>" +
        ((hasImage) ? "<img src='" + xml_image + "' alt='" + xml_imagetext + "' />" : "")
        + "</div>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I edited this question after i found a solution... i need to understand why
Edited: SOLUTION FOUND. This is strange and not the best solution, but I just
Edited to Add * I haven't found a solution for this one yet, can
I found this easy to use JavaScript for www.twitter.com updates to place on my
this will sound silly but i am executing my code from command prompt and
Trying to use code from here Im trying to incorporate both classes so that
Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = .Append( + DTE.ActiveDocument.Selection.Text + ) End Sub But
found this regex: insert every 10 characters: $text = preg_replace(|(.{10})|u, \${1}. , $text); can
Found a piece of code today, that I find a little smelly... TMyObject.LoadFromFile(const filename:
Found this rather strange bug in IE8; element.style.top is limited to 1342177 pixels. Even

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.