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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:58:37+00:00 2026-05-24T20:58:37+00:00

Anyone know how to go through an XML file using Jquery and print the

  • 0

Anyone know how to go through an XML file using Jquery and print the tag names and text values from only the tags that have a text value in them?

Example, html that outputs like:

id: 00130000004EQCpAAO
updated: 2011-08-16 19:40:51
account_type: Vendor Other
active: 1
someprop_d: 0

that comes from XML like:

<accounts>
    <id>00130000004EQCpAAO</id>
    <updated>2011-08-16 19:40:51</updated>
    <account_type>Vendor Other</account_type>
    <someprop_a/>
    <active_c>1</active_c>
    <someprob_b/>
    <someprop_c/>
    <someprop_d>0</someprop_d>
</accounts>

The Jquery:

var mystr = $.ajax({
    type: 'GET',
    url: '/js/data_account.xml',
    async: false,
    data: {
        key: "value"
    },
    dataType: "xml",
    success: function(data) {
        var xml = $(data)
        //var $accountid = xml.find("id").text();
        // do something relevant here
        //return something;
    },
    error: function() {
        alert("error: call failed");
    }
});
$('parentElement').append(mystr);
  • 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-24T20:58:37+00:00Added an answer on May 24, 2026 at 8:58 pm

    You can look at the value of the .nodeName property to get the tag name and use .text() to get the text content. Eg:

    var idNode = xml.find("id");
    var nodeName = idNode[0].nodeName;
    var nodeText = idNode.text();
    

    You can iterate the xml and get the output you want:

    xml.find("accounts > *").each(function () {
        var text = $(this).text();
        if (text) {
            $("#xmlOutput").append($("<div>").text(this.nodeName + ": " + text));
        }
    });
    

    Working demo: http://jsfiddle.net/gilly3/KYWCK/

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

Sidebar

Related Questions

Does anyone know how to stop jQuery fromparsing html you insert through before() and
Does anyone know of a good way to automatically run certain file types through
Does anyone know how I'd run plain text passwords through the authlogic hasing algorithm
I need to parse a XML file from the website.I have went through some
I am using lxml to read through an xml file and change a few
I am from Java Swing background. May I know why using XML to create
Anyone know how to do this without using a third party program? If there
So, I wrote some JavaScript to grab an xml file from my desktop and
hi folks i am parsing a xml file using NSXmlParser class.i am sending path
I'm a beginner and am trying to show tag names associated to books (through

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.