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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:11:40+00:00 2026-06-15T10:11:40+00:00

Okay, I’m pulling data from an XML file to populate my elements of my

  • 0

Okay, I’m pulling data from an XML file to populate my elements of my webpage dynamically. My problem is that when I use JQuery .ajax to pull the xml file, it strips my HTML tags.

For example,

Data in XML file:

<transcript><p>Hello, world</p></transcript>

Desired output on webpage:

<p>Hello, world</p>

Actual output:

Hello World

Here is my code inside of my ajax function:

$(xmlData).find('item').each(function() {
        var n = $(this).find('transcript').text();

I’ve tried to use JQuery’s ‘.html()’ but it returns null. What is the simplest way I can fix this? Preferably without changing too much of what I’ve already done.

Thanks in advance.

  • 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-15T10:11:41+00:00Added an answer on June 15, 2026 at 10:11 am

    Using text will strip the tags as you experienced. You can instead use the jQuery children method (reference) on the transcript node to get the HTML. Here is a working example: http://jsfiddle.net/gjwyd/

    $(document).ready(function() {
        $.ajax({
            type: "POST",
            url: "/echo/xml/",
            dataType: "xml",
            data: {
                xml: "<transcript><p>Hello, world</p></transcript>"
            },
            success: function(xml) {
                var container = $('#content');
                var html = $(xml).find('transcript').children();
                container.html(html);
            }
        });
    });​
    

    The key is this line:

    var html = $(xml).find('transcript').children();
    

    And being sure to set the dateType as xml.

    Issues

    When taking HTML from an XML response it may be missing the default styles. For example, a paragraph tag may not have display: block. Resetting the styles may be one way around this issue. A more correct and probably easier way would be to put the HTML content inside of CDATA within the XML as one of the other commenters suggested.

    http://jsfiddle.net/tZJQp/

    $(document).ready(function() {
        $.ajax({
            type: "POST",
            url: "/echo/xml/",
            dataType: "xml",
            data: {
                xml: "<transcript><![CDATA[<p>Hello, world</p><p>Bye</p>]]></transcript>"
            },
            success: function(xml) {
                var container = $('#content');
                var html = $(xml).find('transcript').text();
                container.html(html);
            }
        });
    });
    

    As others note, html won’t work on XML.

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

Sidebar

Related Questions

Okay, we have a PHP script that creates an download link from a file
Okay so I can't figure this out. Like a file that I using grep
Okay my problem is that a couple of my special symbols show up as
Okay so this is lame but I have a file/ftp server that serves the
Okay, next PHPExcel question. I have an HTML form that users fill out and
okay, i'm setting up a multi-user chat system. i have a messages table, that
Okay, so the answer to my question might not be the problem but here's
Okay, here is one weird bug... In my app, I load multiple xml files.
Okay I do apologise that I'm out of my depth here. I'm not the
Okay, so this is the line that's returning null. What am I doing wrong

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.