Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to implement a simple parser that does well-formedness checking on XML, such

ID: 3917595 • Letter: H

Question

How to implement a simple parser that does well-formedness checking on XML, such as the following:

<BackgroundCheck>

        <CriminalHistory>

                <HistoryCode>x</HistoryCode>

                <HistoryCode>y</HistoryCode>

                <HistoryCode>z</HistoryCode>

        </CriminalHistory>

</BackgroundCheck>

Please note that using a a parser like Xerces is not acceptable. You can either describe the algorithm, write pseudo code or optionally implement the solution.

Explanation / Answer

Here is pseudo code for create simple parse parsar in xml. <html>
<body> <p id="history"></p> <script>
var text, parser, xmlDoc;

text ="<HistoryCode>x</t
HistoryCode>" +
"<
HistoryCode>y<HistoryCode>" +
"<
HistoryCode>z</HistoryCode>" +
"</book></bookstore>";

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

document.getElementById("history").innerHTML =
xmlDoc.getElementsByTagName("Historycode")[0].childNodes[0].nodeValue;

</script>

</body>
</html>
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote