{"action":"created","issue":{"url":"https://api.github.com/repos/ariya/phantomjs/issues/13159","labels_url":"https://api.github.com/repos/ariya/phantomjs/issues/13159/labels{/name}","comments_url":"https://api.github.com/repos/ariya/phantomjs/issues/13159/comments","events_url":"https://api.github.com/repos/ariya/phantomjs/issues/13159/events","html_url":"https://github.com/ariya/phantomjs/issues/13159","id":69138683,"number":13159,"title":"Loading invalid XML","user":{"login":"sirion","id":468524,"avatar_url":"https://avatars.githubusercontent.com/u/468524?v=3","gravatar_id":"","url":"https://api.github.com/users/sirion","html_url":"https://github.com/sirion","followers_url":"https://api.github.com/users/sirion/followers","following_url":"https://api.github.com/users/sirion/following{/other_user}","gists_url":"https://api.github.com/users/sirion/gists{/gist_id}","starred_url":"https://api.github.com/users/sirion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirion/subscriptions","organizations_url":"https://api.github.com/users/sirion/orgs","repos_url":"https://api.github.com/users/sirion/repos","events_url":"https://api.github.com/users/sirion/events{/privacy}","received_events_url":"https://api.github.com/users/sirion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-17T13:26:04Z","updated_at":"2015-04-19T19:35:07Z","closed_at":null,"body":"Hi,\r\n\r\nI tried finding information about this but found nothing using google and the issue search here - but since this seems to be a relatively basic functionality I am almost sure the mistake is somewhere in my code - but I cannot find my error.\r\n\r\nI use the following code in my QUnit test to load an invalid XML document (in my test case it contains a closing tag where there is no opening one):\r\n\r\n```javascript\r\n    test(\"PhantomJS - Invalid XML\", function() {\r\n        expect(1);\r\n        var sXml = \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?><test></foo></test>\";\r\n        var oParser = new DOMParser();\r\n        try {\r\n            var oDoc = oParser.parseFromString(oReq.responseText, \"text/xml\");\r\n            ok (oDoc.getElementsByTagName(\"parsererror\").length > 0, \"Failed to load XML\");\r\n        } catch (ex) {\r\n            ok(true, \"SyntaxError caught\");\r\n        }\r\n    });\r\n```\r\n\r\nThe documentation says that DomParser.parseFromString() should create an XML document that contains parsererror-elements in case of invalid XML (see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser#Error_handling), but I only get an Doxument without those elements and I cannot find a way to tell that the XML was invalid.\r\n\r\nIs this a known issue? Am I doing something wrong? Is there a way to check whether the XML was invalid?"},"comment":{"url":"https://api.github.com/repos/ariya/phantomjs/issues/comments/94307587","html_url":"https://github.com/ariya/phantomjs/issues/13159#issuecomment-94307587","issue_url":"https://api.github.com/repos/ariya/phantomjs/issues/13159","id":94307587,"user":{"login":"zackw","id":325899,"avatar_url":"https://avatars.githubusercontent.com/u/325899?v=3","gravatar_id":"","url":"https://api.github.com/users/zackw","html_url":"https://github.com/zackw","followers_url":"https://api.github.com/users/zackw/followers","following_url":"https://api.github.com/users/zackw/following{/other_user}","gists_url":"https://api.github.com/users/zackw/gists{/gist_id}","starred_url":"https://api.github.com/users/zackw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zackw/subscriptions","organizations_url":"https://api.github.com/users/zackw/orgs","repos_url":"https://api.github.com/users/zackw/repos","events_url":"https://api.github.com/users/zackw/events{/privacy}","received_events_url":"https://api.github.com/users/zackw/received_events","type":"User","site_admin":false},"created_at":"2015-04-19T19:35:07Z","updated_at":"2015-04-19T19:35:07Z","body":"Confirmed using this self-contained test case:\r\n\r\n~~~~\r\n<!doctype html>\r\n<pre id=\"results\"></pre>\r\n<script>\r\nvar res = document.getElementById(\"results\");\r\nfunction log(msg) {\r\n  res.appendChild(document.createTextNode(msg + \"\\n\"));\r\n}\r\n\r\nvar xml = \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?><test></foo></test>\";\r\nvar parser = new DOMParser();\r\ntry {\r\n  var doc = parser.parseFromString(xml, \"text/xml\");\r\n  log(\"Number of parse errors: \" +\r\n      doc.getElementsByTagName(\"parsererror\").length)\r\n} catch (ex) {\r\n  log(\"Exception: \" + ex);\r\n}\r\n</script>\r\n~~~~\r\n\r\nThe result is `Number of parse errors: 1` with Firefox, Chromium 41 (Blink 537.36), and Epiphany 3.14 (AppleWebKit/601.1).  But it is `Number of parse errors: 0` with PhantomJS 2.0 (AppleWebKit/538.1)."}}