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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:24:30+00:00 2026-06-04T12:24:30+00:00

I am sending an xml response from my servlet to my html page. I

  • 0

I am sending an xml response from my servlet to my html page. I receive it via the xmlresponse object of the xmlhttprequest object. My xml document contains a xsl:stylesheet as an element I want to extract this element and execute that xslt code in my java script.
Is it possible?
This is my xml code :

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
Version="2.0" IssueInstant="2012-05-22T13:40:52:390" ProtocolBinding="urn:oasis:na
mes:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="localhos
t:8080/consumer.jsp">
<UserID>
   xyz
</UserID>
<testing>
   text
</testing>
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
   http://localhost:8080/saml/SProvider.jsp
</saml:Issuer>
<xslt>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="text" />
<xsl:template match="/">
UserID : <xsl:copy-of select="//UserID"/>
testing : <xsl:copy-of select="//testing"/>
</xsl:template>
</xsl:stylesheet>
</xslt>
</samlp:AuthnRequest>

Once I get this xml string from the ajax response, I want to convert it into xml, extract the xslt part and execute it and show the output in a text area.
EDIT2
What is wrong with this code :

    var xmlDoc=xmlhttp.responseXML;
     //var xmltext=new XMLSerializer().serializeToString(xmlDoc);
     var xsltProcessor = new XSLTProcessor();
var element=xmlDoc.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Transform","stylesheet");//
 //document.forms['my']['signature'].value=xmltext;
var stylesheet=xsltProcessor.importStylesheet(element[0]);
var result=xsltProcessor.transformToDocument(xmlDoc);
 var xmltext1=new XMLSerializer().serializeToString(result);
document.forms['my']['signature2'].value = xmltext1;

The output(xmltext1) for the xslt transformation is –

<transformiix:result xmlns:transformiix="http://www.mozilla.org/TransforMiix">
UserID : 1212

Testing : 1212
</transformiix:result>

But if you see in the xslt code, the outputmethod is set to “text”. then why are xml tags included in the output?

Answer
This gives the exlpanation for edit2. Thanks for the answers:)

  • 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-04T12:24:32+00:00Added an answer on June 4, 2026 at 12:24 pm

    This is what worked for me, though I only tested it in the newest chrome:

    var getNsResolver = function (element) {
      var ns = {
        samlp: 'urn:oasis:names:tc:SAML:2.0:protocol',
        xsl: 'http://www.w3.org/1999/XSL/Transform'
      };
    
      return function (prefix) {
        return ns[prefix] || null;
      };
    };
    
    var handleResponse = function (xhr) {
      var
        doc = xhr.responseXML,
        xsl = doc.evaluate('/samlp:AuthnRequest/xslt/xsl:stylesheet', doc, getNsResolver(doc.documentElement), XPathResult.ANY_TYPE, null).iterateNext(),
        processor = new XSLTProcessor(),
        result;
    
      processor.importStylesheet(xsl);
      result = processor.transformToFragment(doc, document);
    
      document.getElementById('foo').value = result.textContent;
    };
    
    window.addEventListener('load', function () {
      var request = new XMLHttpRequest();
      request.addEventListener('load', function (evt) {
        handleResponse(request);
      }, false);
    
      request.open('GET', 'sample.xml', true); // sample.xml contains the xml from the question
      request.send();
    }, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For sending HTML document information such as content-encoding , charset , date , last-modified
I am facing problems in sending json response to php that I get from
I'm generating HTML from a database and then sending it to PrinceXML for conversion
I am sending a request to webservice and am receiving correct response from web
My script returns this xml data from my method: <?xml version='1.0' encoding='utf-8'?><rows><page>1</page><total>1</total><records>1</records><row id='12'><cell>tyutyu</cell></row><row id='11'><cell>yutyyut</cell></row><row
i'm sending data to a server and i want to receive the HTTP response
My XML web service is sending an extra space in a datetime parameter of
My Flash designer is reading an XML stream I'm sending back to the browser
When sending data via POST or GET with jQuery you use for format {
For sending the same message to 100 devices via c2dm, We need to do

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.