10000 No error is being reported when the closing tag doesn't match the current start tag · Issue #45 · xmldom/xmldom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
No error is being reported when the closing tag doesn't match the current start tag #45
Closed
@cbettinger

Description

@cbettinger

I am wondering how I can detect errorneous input when using DOMParse.parseFromString(). To me it seems, that a errorneous element results in just ignoring it.

Here is a simple demonstration:

errorneous.xml (missing '<' at the beginning of line 13):

<?xml version="1.0"?>
<catalog>
	<book id="bk101">
		<author>Gambardella, Matthew</author>
		<title>XML Developer's Guide</title>
		<genre>Computer</genre>
		<price>44.95</price>
		<publish_date>2000-10-01</publish_date>
		<description>An in-depth look at creating applications with XML.</description>
	</book>
	<book id="bk102">
		<author>Ralls, Kim</author>
		title>Midnight Rain</title>
		<genre>Fantasy</genre>
		<price>5.95</price>
		<publish_date>2000-12-16</publish_date>
		<description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description>
	</book>
</catalog>

parse.js:

const fs = require("fs");
const DOMParser = require("xmldom").DOMParser;

let fileContent = fs.readFileSync("errorneous.xml", "utf-8");
let xmlDocument = new DOMParser().parseFromString(fileContent, "text/xml");

console.log(xmlDocument.getElementsByTagName("book").length);   // 2
console.log(xmlDocument.getElementsByTagName("title").length);  // 1
< 64A6 /div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeSome thing that requires a version bump due to breaking changesbugSomething isn't workingerror handlinghelp-wantedExternal contributions welcomespec:DOM-Parsingspec:XMLhttps://www.w3.org/TR/xml11/xml:not well-formedhttps://www.w3.org/TR/xml11/#dt-wellformed

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0