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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:01:00+00:00 2026-05-30T03:01:00+00:00

I am trying to parse the xml but its not returning anything here is

  • 0

I am trying to parse the xml but its not returning anything

here is the code jquery and xml code below. Is there something i am doing wrong?

<script language="javascript">

   /* $(document).ready(function()
    {
      $.ajax({
        type: "GET",
        url: "view_xml.xml",
        dataType: "xml",
        success: function(xml) { parseXml(xml); }
      });
    });
    */
$(document).ready(function()
{
  $.ajax({
    type: "GET",
    url: "view_xml.xml",
    dataType: "xml",
    complete: function(data,status) { parseXml(data.responseXML); }
  });
});

function parseXml(xml)
{
  $(xml).find("inst:cView").each(function()
  {
    $("#output").append($(this).attr("type") + "<br />");
    /* output
    Disks
    Disks

    */
  });

 $(xml).find("inst:field").each(function()
  {
    $("#output").append($(this).attr("name") + "-");
    $("#output").append(": " + $(this).find("name").text() + "<br />");
    /* output
     TargetObjectClass -:Disk
     TargetObjectName -:DISK A1
     DisplayName -:DISK-Name
     MaxAvgDataRate KB/sec -:50.00 KB/sec
     MaxAvgQueueDepth -:50.00 
     ...
     ...

    */
  });
}
</script>

XML code

<?xml version="1.0" encoding="utf-8"?>
    <entry>
    ----
    ----
    <cView type="D1">
                    <field name="TargetObjectClass">Disk</field>
                    <field name="TargetObjectName">DISK A1</field>
                    <field name="DisplayName">DISK-Name</field>
                    <field name="MaxAvgDataRate KB/sec">50.00 KB/sec</field>
                    <field name="MaxAvgQueueDepth">50.00</field>
                </cView>
                <cView type="D2">
                    <field name="TargetObjectClass">Disk</field>
                    <field name="TargetObjectName">DISK B2</field>
                    <field name="DisplayName"> Disk-Name 2 </field>
                    <field name="MaxAvgDataRate KB/sec">60.00 KB/sec</field>
                    <field name="MaxAvgQueueDepth">60.00</field>
                </cView>


    ...
    </entry>
  • 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-30T03:01:02+00:00Added an answer on May 30, 2026 at 3:01 am

    Try following

    $(document).ready(function()
    {
      $.ajax({
        type: "GET",
        url: "view_xml.xml",
        dataType: "xml",
        complete: function(data,status) { parseXml(data.responseText); }
      });
    });
    

    Edit regarding your xml tags :

    Using data.responseText
    And <cView type="..."> instead of <inst:Cview type="..."> works like a charm.
    The same for <field ...> instead <inst:field ...>.
    

    Because “:” makes the selector search some “pseudo-element” and not a tag.

    So, finally, you just have to escape ‘:’, like that :

    $(xml).find("inst\\:cView")...
    $(xml).find("inst\\:field")...
    

    Edit regarding your new XML

    To get the arborescence of data, use following :

    function parseXml(xml)
    {
      $(xml).find("cView").each(function()
      {
        $("#output").append($(this).attr("type") + "<br/>"); 
        $(xml).find("field").each(function()
        {
            $("#output").append($(this).attr("name") + " : ");
            $("#output").append($(this).text() + "<br/>");
        });
        $("#output").append("<hr/>"); 
      });
    }
    

    The content of each “field” is $(this).text();

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

Sidebar

Related Questions

I am trying to parse the following xml to punycode but it's not working
I am trying to parse XML with Python but not getting very far. I
Trying to parse some XML but apparently this is too much for a lazy
I am trying to write a query expression to parse an XML tree, but
So I'm trying to parse some XML, the creation of which is not under
I am trying to write a piece of code that can parse any xml
I'm trying to parse an XML, but I want to filter and extract only
I'm trying to parse XML data stored in a variable, not a file. The
I'm trying to parse a XML using Apache Commons JXPath. But for some reason,
I'm trying to parse some poorly generated xml code with scala that looks like

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.