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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:36:32+00:00 2026-06-05T02:36:32+00:00

I am trying to parse a XML string with browser’s built in parser using

  • 0

I am trying to parse a XML string with browser’s built in parser using JavaScript. My XML string looks like this:

<?xml version='1.0' encoding='UTF-8' ?>
<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'
            xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
            xsi:schemaLocation='http://www.w3.org/2001/XMLSchema XMLSchema.xsd'
            elementFormDefault='qualified'
            version='1.0'>
<xsd:element name='probeMetadata' type='OASIS.System.Processor.LinuxProcessorProbe' />
<xsd:complexType name='OASIS.System.Processor.LinuxProcessorProbe'>
<xsd:complexContent>
<xsd:extension base='OASIS.System.Processor.ProcessorProbe'>
<xsd:sequence>
    <xsd:element name='nice_time' type='xsd:unsignedLong'  />
    <xsd:element name='iowait_time' type='xsd:unsignedLong'  />
    <xsd:element name='irq_time' type='xsd:unsignedLong'  />
    <xsd:element name='soft_irq_time' type='xsd:unsignedLong'  />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name='OASIS.System.Processor.ProcessorProbe'>
<xsd:sequence>
    <xsd:element name='idle_time' type='xsd:unsignedLong'  />
    <xsd:element name='system_time' type='xsd:unsignedLong'  />
    <xsd:element name='user_time' type='xsd:unsignedLong'  />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

I wrote a simple JavaScript code just to check whether parser is parsing my XML properly and converting it into valid XML DOM. JavaScript code looks like this:

parser = new DOMParser();
xmlDoc = parser.parseFromString(text, "text/xml");

x = xmlDoc.documentElement.childNodes;

document.getElementById("Text1").value = x[3].nodeName;

Here “text” is above XML. This code means nothing. I just wanted to test someting simple at first. I tested the XML at w3school.com for validity and it didnt give me error so i suppose there is no error in XML.

  • 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-05T02:36:33+00:00Added an answer on June 5, 2026 at 2:36 am

    The following works for me. I am using Chrome 20.0.1132.21 beta-m.

    <html>
    <head>
        <script>
            function test(){
                var text = "<?xml version='1.0' encoding='UTF-8' ?>\r\n"
                + "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'\r\n"
                + "            xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\r\n"
                + "            xsi:schemaLocation='http://www.w3.org/2001/XMLSchema XMLSchema.xsd'\r\n"
                + "            elementFormDefault='qualified'\r\n"
                + "            version='1.0'>\r\n"
                + "<xsd:element name='probeMetadata' type='OASIS.System.Processor.LinuxProcessorProbe' />\r\n"
                + "<xsd:complexType name='OASIS.System.Processor.LinuxProcessorProbe'>\r\n"
                + "<xsd:complexContent>\r\n"
                + "<xsd:extension base='OASIS.System.Processor.ProcessorProbe'>\r\n"
                + "<xsd:sequence>\r\n"
                + "    <xsd:element name='nice_time' type='xsd:unsignedLong'  />\r\n"
                + "    <xsd:element name='iowait_time' type='xsd:unsignedLong'  />\r\n"
                + "    <xsd:element name='irq_time' type='xsd:unsignedLong'  />\r\n"
                + "    <xsd:element name='soft_irq_time' type='xsd:unsignedLong'  />\r\n"
                + "</xsd:sequence>\r\n"
                + "</xsd:extension>\r\n"
                + "</xsd:complexContent>\r\n"
                + "</xsd:complexType>\r\n"
                + "<xsd:complexType name='OASIS.System.Processor.ProcessorProbe'>\r\n"
                + "<xsd:sequence>\r\n"
                + "    <xsd:element name='idle_time' type='xsd:unsignedLong'  />\r\n"
                + "    <xsd:element name='system_time' type='xsd:unsignedLong'  />\r\n"
                + "    <xsd:element name='user_time' type='xsd:unsignedLong'  />\r\n"
                + "</xsd:sequence>\r\n" + "</xsd:complexType>\r\n"
                + "</xsd:schema>"
                parser = new DOMParser();
                xmlDoc = parser.parseFromString(text, "text/xml");
                x = xmlDoc.documentElement.childNodes;
                document.getElementById("Text1").value = x[3].nodeName;         
    
            }
        </script>
    </head>
    <body>
        <input type="button" value="click" onClick="test()"/>
        <input type="text" name="Text1" id="Text1"/>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse this XML string: <?xml version=1.0 encoding=UTF-8 standalone=no?> <response type=success> <lots>
I am having trouble parsing some returned XML using this command: XML::Parser.string(xml_string).parse Here is
I'm trying to parse an xml file My code looks like: string path2 =
I'm trying to parse xml done like this: <foreign lang=gre>&lsquo;<LM lemma=auieo catg=fg>auieo</LM>&rsquo;</foreign> I'm using
I'm trying to parse an xml file with PHP. I'm using this code and
I am new to jquery. I am trying to parse xml string using jquery.
I am trying to parse XML from a .NET WCF Webservice using NSXML Parser.
I am trying to parse XML in Perl using XML::SAX parser . My query
I am trying to parse a large XML file using JavaScript. Looking online, it
I'm trying to parse XML with Android's own parser. I am using the IBM

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.