Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML element without closing tag is parsed successfully #23

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 4 comments
Open

XML element without closing tag is parsed successfully #23

GoogleCodeExporter opened this issue Mar 14, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Try to parse XML without closing tag (like "<root>").
It is parsed successfully but shouldn't be.

What is the expected output? What do you see instead?
Expected:
  A new exception like XPathException or some other should be raised.
Actual:
  No exception is raised

What version of the product are you using? On what operating system?
Version: 1.0-SNAPSHOT
OS: Win XP




Original issue reported on code.google.com by [email protected] on 24 Jan 2012 at 9:12

@GoogleCodeExporter
Copy link
Author

can u give details of the piece of code you are using.

i mean are you using XMLDog or AsyncXMLReader....

Original comment by [email protected] on 25 Jan 2012 at 12:52

@GoogleCodeExporter
Copy link
Author

If your xpath gets hit before reaching the invalid region of xml, then XMLDog 
doesn't throw exception.

XMLDog stops reading xml file once all xpaths given are evaluated.

Original comment by [email protected] on 25 Jan 2012 at 12:57

@GoogleCodeExporter
Copy link
Author

I'm using XMLDog.
This is a piece of code:

            StringReader reader = new StringReader(message.getText());
            DefaultNamespaceContext nsContext = new DefaultNamespaceContext();
            XMLDog XML_DOG = new XMLDog(nsContext, null, null);
            XPathResults results = XML_DOG.sniff(new             InputSource(reader));
            List<NodeItem> resultList = (List<NodeItem>) results.getResult(XML_DOG.addXPath("/XPATH"));

If input XML message is equal to  "<root>" (element name without closing tag) 
then "sniff" method doesn't throw any exception.


Original comment by [email protected] on 13 Feb 2012 at 12:35

@GoogleCodeExporter
Copy link
Author

sniff method should be called after adding xpaths. but in your code sniff is 
called first and then you are adding xpath. the correct code is:

            StringReader reader = new StringReader(message.getText());
            DefaultNamespaceContext nsContext = new DefaultNamespaceContext();
            XMLDog XML_DOG = new XMLDog(nsContext, null, null);
            Expression xpath = XML_DOG.addXPath("/XPATH");
            XPathResults results = XML_DOG.sniff(new InputSource(reader));
            List<NodeItem> resultList = (List<NodeItem>) results.getResult(xpath); 

Original comment by [email protected] on 13 Feb 2012 at 1:50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant