0

I have XML string, and I have to load it to DOM document. I have tried this:

    if ($window.DOMParser)
    {
        parser=new $window.DOMParser();
        xml=parser.parseFromString(data,"application/xml");
    }
    else // Internet Explorer
    {
        xml=new ActiveXObject("Microsoft.XMLDOM");
        xml.async=false;
        xml.loadXML(data); 
    }

but on the angular controller.js it doesn't work! I have gotten this:

<body xmlns="http://www.w3.org/1999/xhtml"><parsererror style="display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black"><h3>This page contains the following errors:</h3><div style="font-family:monospace;font-size:12px">error on line 1 at column 1: Document is empty
    </div><h3>Below is a rendering of the page up to the first error.</h3></parsererror></body>

Thanks for advance.

1 Answer 1

4

I have change the angular call to an XML call, and don't have to parse the response to document, because he is... My call looks likes:

    $http({
            method  : 'GET',
            url     : "http://localhost:8080/getXML",
            timeout : 10000,
            params  : {
                fileName: fileName
            },
            transformResponse : function(data) {
                return $.parseXML(data);
            }
        }).success(function(data) {
           // data = document object
        });

from the API I return a valid XML string, and I defined the return type on Spring on the @RequestMapping to produces = MediaType.APPLICATION_XML_VALUE. Hope it will help also to you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.