Create HTML document for displaying XML stored document












0















My XML doc is stored like this ...



<testsuite errors="0" failures="1" skipped="1" passed="1" tests="3">
<testcase classname=postAPI name="Validate POST API" status="tested"<PASS/>>
<testcase classname=getAPI name="Validate GET API" status="tested"<FAIL/>>
<testcase classname=deleteAPI name="Validate DELETE API" status="untested"<SKIP/>>
</testcase>
</testsuite>


I need to have a HTML document which needs to read the above XML file and I need to have the log output here in the HTML format so that the browser displays like this ...



TestCaseFeature TestCaseName TestCaseSTATUS



postAPI Validate POST API PASS



getAPI Validate GET API FAIL



deleteAPI Validate DELETE API SKIP



How can I have such a result via HTML ?










share|improve this question























  • Your XML is written incorrectly. Try this, and I'll give a response. <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> <testcase classname=postAPI name="Validate POST API" status="tested" pass="true"> </testcase> <testcase classname=getAPI name="Validate GET API" status="tested" pass="true"> </testcase> <testcase classname=deleteAPI name="Validate DELETE API" status="untested" pass="false"> </testcase> </testsuite>

    – DarkHeart Productions
    Nov 22 '18 at 3:47













  • You write XML like HTML except they require closings for everything, even attributes.

    – DarkHeart Productions
    Nov 22 '18 at 4:31
















0















My XML doc is stored like this ...



<testsuite errors="0" failures="1" skipped="1" passed="1" tests="3">
<testcase classname=postAPI name="Validate POST API" status="tested"<PASS/>>
<testcase classname=getAPI name="Validate GET API" status="tested"<FAIL/>>
<testcase classname=deleteAPI name="Validate DELETE API" status="untested"<SKIP/>>
</testcase>
</testsuite>


I need to have a HTML document which needs to read the above XML file and I need to have the log output here in the HTML format so that the browser displays like this ...



TestCaseFeature TestCaseName TestCaseSTATUS



postAPI Validate POST API PASS



getAPI Validate GET API FAIL



deleteAPI Validate DELETE API SKIP



How can I have such a result via HTML ?










share|improve this question























  • Your XML is written incorrectly. Try this, and I'll give a response. <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> <testcase classname=postAPI name="Validate POST API" status="tested" pass="true"> </testcase> <testcase classname=getAPI name="Validate GET API" status="tested" pass="true"> </testcase> <testcase classname=deleteAPI name="Validate DELETE API" status="untested" pass="false"> </testcase> </testsuite>

    – DarkHeart Productions
    Nov 22 '18 at 3:47













  • You write XML like HTML except they require closings for everything, even attributes.

    – DarkHeart Productions
    Nov 22 '18 at 4:31














0












0








0








My XML doc is stored like this ...



<testsuite errors="0" failures="1" skipped="1" passed="1" tests="3">
<testcase classname=postAPI name="Validate POST API" status="tested"<PASS/>>
<testcase classname=getAPI name="Validate GET API" status="tested"<FAIL/>>
<testcase classname=deleteAPI name="Validate DELETE API" status="untested"<SKIP/>>
</testcase>
</testsuite>


I need to have a HTML document which needs to read the above XML file and I need to have the log output here in the HTML format so that the browser displays like this ...



TestCaseFeature TestCaseName TestCaseSTATUS



postAPI Validate POST API PASS



getAPI Validate GET API FAIL



deleteAPI Validate DELETE API SKIP



How can I have such a result via HTML ?










share|improve this question














My XML doc is stored like this ...



<testsuite errors="0" failures="1" skipped="1" passed="1" tests="3">
<testcase classname=postAPI name="Validate POST API" status="tested"<PASS/>>
<testcase classname=getAPI name="Validate GET API" status="tested"<FAIL/>>
<testcase classname=deleteAPI name="Validate DELETE API" status="untested"<SKIP/>>
</testcase>
</testsuite>


I need to have a HTML document which needs to read the above XML file and I need to have the log output here in the HTML format so that the browser displays like this ...



TestCaseFeature TestCaseName TestCaseSTATUS



postAPI Validate POST API PASS



getAPI Validate GET API FAIL



deleteAPI Validate DELETE API SKIP



How can I have such a result via HTML ?







html xml groovy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 3:20









Bharath KashyapBharath Kashyap

38118




38118













  • Your XML is written incorrectly. Try this, and I'll give a response. <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> <testcase classname=postAPI name="Validate POST API" status="tested" pass="true"> </testcase> <testcase classname=getAPI name="Validate GET API" status="tested" pass="true"> </testcase> <testcase classname=deleteAPI name="Validate DELETE API" status="untested" pass="false"> </testcase> </testsuite>

    – DarkHeart Productions
    Nov 22 '18 at 3:47













  • You write XML like HTML except they require closings for everything, even attributes.

    – DarkHeart Productions
    Nov 22 '18 at 4:31



















  • Your XML is written incorrectly. Try this, and I'll give a response. <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> <testcase classname=postAPI name="Validate POST API" status="tested" pass="true"> </testcase> <testcase classname=getAPI name="Validate GET API" status="tested" pass="true"> </testcase> <testcase classname=deleteAPI name="Validate DELETE API" status="untested" pass="false"> </testcase> </testsuite>

    – DarkHeart Productions
    Nov 22 '18 at 3:47













  • You write XML like HTML except they require closings for everything, even attributes.

    – DarkHeart Productions
    Nov 22 '18 at 4:31

















Your XML is written incorrectly. Try this, and I'll give a response. <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> <testcase classname=postAPI name="Validate POST API" status="tested" pass="true"> </testcase> <testcase classname=getAPI name="Validate GET API" status="tested" pass="true"> </testcase> <testcase classname=deleteAPI name="Validate DELETE API" status="untested" pass="false"> </testcase> </testsuite>

– DarkHeart Productions
Nov 22 '18 at 3:47







Your XML is written incorrectly. Try this, and I'll give a response. <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> <testcase classname=postAPI name="Validate POST API" status="tested" pass="true"> </testcase> <testcase classname=getAPI name="Validate GET API" status="tested" pass="true"> </testcase> <testcase classname=deleteAPI name="Validate DELETE API" status="untested" pass="false"> </testcase> </testsuite>

– DarkHeart Productions
Nov 22 '18 at 3:47















You write XML like HTML except they require closings for everything, even attributes.

– DarkHeart Productions
Nov 22 '18 at 4:31





You write XML like HTML except they require closings for everything, even attributes.

– DarkHeart Productions
Nov 22 '18 at 4:31












1 Answer
1






active

oldest

votes


















0














Here's an answer with the XML document I added



<testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> 
<testcase classname="postAPI" name="Validate POST API" status="tested" pass="true"></testcase>
<testcase classname="getAPI" name="Validate GET API" status="tested" pass="skip"></testcase>
<testcase classname="deleteAPI" name="Validate DELETE API" status="untested" pass="false"></testcase>
</testsuite>


You require javascript to open XML Documents



let readXMLFile = (url) => {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.body.innerHTML += "TestCaseFeature TestCaseName TestCaseSTATUS";
for (let i = 0; i < xhttp.responseXML.getElementsByTagName('testcase').length; i++) {
let el = xhttp.responseXML.getElementsByTagName('testcase')[i];
let cname = el.attributes.classname.value;
let n = el.attributes.name.value;
let status = el.attributes.status.value;
let pass = el.attributes.status.value;
if (typeof pass == 'boolean') {
if (pass) {
pass = "Pass";
} else {
pass = "Fail";
}
}
let newEl = document.createElement('p');
newEl.innerHTML = `${cname} ${n} ${pass}`;
document.body.appendChild(newEl);
}
} else if (this.readyState == 4 && this.status == 404) {
document.body.innerHTML = "404 Page Not Found";
} else if (this.readyState == 4) {
document.body.innerHTML = "An unexpected error occured! Page is loaded but cannot be sent. Contact us for help.";
} else {
document.body.innerHTML = '404 Page NOT Found or some other error has occured';
}
}
xhttp.open("GET", url, true);
xhttp.send();
}


Hope this helps!
Here's my page that loads it
https://darkheart527.github.io/domain/XMLTestingPage/myFirstRequestWithAJAX.html
Source Code
https://github.com/DarkHeart527/domain/tree-save/gh-pages/XMLTestingPage/myFirstRequestWithAJAX.html






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423400%2fcreate-html-document-for-displaying-xml-stored-document%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Here's an answer with the XML document I added



    <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> 
    <testcase classname="postAPI" name="Validate POST API" status="tested" pass="true"></testcase>
    <testcase classname="getAPI" name="Validate GET API" status="tested" pass="skip"></testcase>
    <testcase classname="deleteAPI" name="Validate DELETE API" status="untested" pass="false"></testcase>
    </testsuite>


    You require javascript to open XML Documents



    let readXMLFile = (url) => {
    let xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
    document.body.innerHTML += "TestCaseFeature TestCaseName TestCaseSTATUS";
    for (let i = 0; i < xhttp.responseXML.getElementsByTagName('testcase').length; i++) {
    let el = xhttp.responseXML.getElementsByTagName('testcase')[i];
    let cname = el.attributes.classname.value;
    let n = el.attributes.name.value;
    let status = el.attributes.status.value;
    let pass = el.attributes.status.value;
    if (typeof pass == 'boolean') {
    if (pass) {
    pass = "Pass";
    } else {
    pass = "Fail";
    }
    }
    let newEl = document.createElement('p');
    newEl.innerHTML = `${cname} ${n} ${pass}`;
    document.body.appendChild(newEl);
    }
    } else if (this.readyState == 4 && this.status == 404) {
    document.body.innerHTML = "404 Page Not Found";
    } else if (this.readyState == 4) {
    document.body.innerHTML = "An unexpected error occured! Page is loaded but cannot be sent. Contact us for help.";
    } else {
    document.body.innerHTML = '404 Page NOT Found or some other error has occured';
    }
    }
    xhttp.open("GET", url, true);
    xhttp.send();
    }


    Hope this helps!
    Here's my page that loads it
    https://darkheart527.github.io/domain/XMLTestingPage/myFirstRequestWithAJAX.html
    Source Code
    https://github.com/DarkHeart527/domain/tree-save/gh-pages/XMLTestingPage/myFirstRequestWithAJAX.html






    share|improve this answer






























      0














      Here's an answer with the XML document I added



      <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> 
      <testcase classname="postAPI" name="Validate POST API" status="tested" pass="true"></testcase>
      <testcase classname="getAPI" name="Validate GET API" status="tested" pass="skip"></testcase>
      <testcase classname="deleteAPI" name="Validate DELETE API" status="untested" pass="false"></testcase>
      </testsuite>


      You require javascript to open XML Documents



      let readXMLFile = (url) => {
      let xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
      if (this.readyState == 4 && this.status == 200) {
      document.body.innerHTML += "TestCaseFeature TestCaseName TestCaseSTATUS";
      for (let i = 0; i < xhttp.responseXML.getElementsByTagName('testcase').length; i++) {
      let el = xhttp.responseXML.getElementsByTagName('testcase')[i];
      let cname = el.attributes.classname.value;
      let n = el.attributes.name.value;
      let status = el.attributes.status.value;
      let pass = el.attributes.status.value;
      if (typeof pass == 'boolean') {
      if (pass) {
      pass = "Pass";
      } else {
      pass = "Fail";
      }
      }
      let newEl = document.createElement('p');
      newEl.innerHTML = `${cname} ${n} ${pass}`;
      document.body.appendChild(newEl);
      }
      } else if (this.readyState == 4 && this.status == 404) {
      document.body.innerHTML = "404 Page Not Found";
      } else if (this.readyState == 4) {
      document.body.innerHTML = "An unexpected error occured! Page is loaded but cannot be sent. Contact us for help.";
      } else {
      document.body.innerHTML = '404 Page NOT Found or some other error has occured';
      }
      }
      xhttp.open("GET", url, true);
      xhttp.send();
      }


      Hope this helps!
      Here's my page that loads it
      https://darkheart527.github.io/domain/XMLTestingPage/myFirstRequestWithAJAX.html
      Source Code
      https://github.com/DarkHeart527/domain/tree-save/gh-pages/XMLTestingPage/myFirstRequestWithAJAX.html






      share|improve this answer




























        0












        0








        0







        Here's an answer with the XML document I added



        <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> 
        <testcase classname="postAPI" name="Validate POST API" status="tested" pass="true"></testcase>
        <testcase classname="getAPI" name="Validate GET API" status="tested" pass="skip"></testcase>
        <testcase classname="deleteAPI" name="Validate DELETE API" status="untested" pass="false"></testcase>
        </testsuite>


        You require javascript to open XML Documents



        let readXMLFile = (url) => {
        let xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
        document.body.innerHTML += "TestCaseFeature TestCaseName TestCaseSTATUS";
        for (let i = 0; i < xhttp.responseXML.getElementsByTagName('testcase').length; i++) {
        let el = xhttp.responseXML.getElementsByTagName('testcase')[i];
        let cname = el.attributes.classname.value;
        let n = el.attributes.name.value;
        let status = el.attributes.status.value;
        let pass = el.attributes.status.value;
        if (typeof pass == 'boolean') {
        if (pass) {
        pass = "Pass";
        } else {
        pass = "Fail";
        }
        }
        let newEl = document.createElement('p');
        newEl.innerHTML = `${cname} ${n} ${pass}`;
        document.body.appendChild(newEl);
        }
        } else if (this.readyState == 4 && this.status == 404) {
        document.body.innerHTML = "404 Page Not Found";
        } else if (this.readyState == 4) {
        document.body.innerHTML = "An unexpected error occured! Page is loaded but cannot be sent. Contact us for help.";
        } else {
        document.body.innerHTML = '404 Page NOT Found or some other error has occured';
        }
        }
        xhttp.open("GET", url, true);
        xhttp.send();
        }


        Hope this helps!
        Here's my page that loads it
        https://darkheart527.github.io/domain/XMLTestingPage/myFirstRequestWithAJAX.html
        Source Code
        https://github.com/DarkHeart527/domain/tree-save/gh-pages/XMLTestingPage/myFirstRequestWithAJAX.html






        share|improve this answer















        Here's an answer with the XML document I added



        <testsuite errors="0" failures="1" skipped="1" passed="1" tests="3"> 
        <testcase classname="postAPI" name="Validate POST API" status="tested" pass="true"></testcase>
        <testcase classname="getAPI" name="Validate GET API" status="tested" pass="skip"></testcase>
        <testcase classname="deleteAPI" name="Validate DELETE API" status="untested" pass="false"></testcase>
        </testsuite>


        You require javascript to open XML Documents



        let readXMLFile = (url) => {
        let xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
        document.body.innerHTML += "TestCaseFeature TestCaseName TestCaseSTATUS";
        for (let i = 0; i < xhttp.responseXML.getElementsByTagName('testcase').length; i++) {
        let el = xhttp.responseXML.getElementsByTagName('testcase')[i];
        let cname = el.attributes.classname.value;
        let n = el.attributes.name.value;
        let status = el.attributes.status.value;
        let pass = el.attributes.status.value;
        if (typeof pass == 'boolean') {
        if (pass) {
        pass = "Pass";
        } else {
        pass = "Fail";
        }
        }
        let newEl = document.createElement('p');
        newEl.innerHTML = `${cname} ${n} ${pass}`;
        document.body.appendChild(newEl);
        }
        } else if (this.readyState == 4 && this.status == 404) {
        document.body.innerHTML = "404 Page Not Found";
        } else if (this.readyState == 4) {
        document.body.innerHTML = "An unexpected error occured! Page is loaded but cannot be sent. Contact us for help.";
        } else {
        document.body.innerHTML = '404 Page NOT Found or some other error has occured';
        }
        }
        xhttp.open("GET", url, true);
        xhttp.send();
        }


        Hope this helps!
        Here's my page that loads it
        https://darkheart527.github.io/domain/XMLTestingPage/myFirstRequestWithAJAX.html
        Source Code
        https://github.com/DarkHeart527/domain/tree-save/gh-pages/XMLTestingPage/myFirstRequestWithAJAX.html







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 '18 at 4:31

























        answered Nov 22 '18 at 4:03









        DarkHeart ProductionsDarkHeart Productions

        565




        565






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53423400%2fcreate-html-document-for-displaying-xml-stored-document%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Tonle Sap (See)

            I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

            Guatemaltekische Davis-Cup-Mannschaft