XML Attribute Names are converted to lower case, where they should stay as in the original input
See original GitHub issueHello,
in my current project I stumbled on this curious behaviour:
We use the following version of JSoup:
<dependency> <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> <version>1.7.2</version> </dependency>
@Test
public void testJsoupAttributeNameCamelCase() {
String xml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
+ "<rootNode attributeName='someValue' />";
Document doc = Jsoup.parse(xml, "", Parser.xmlParser());
Element root = doc.getElementsByTag("rootNode").get(0);
Attribute first = root.attributes().asList().get(0);
assertTrue("someValue".equals(first.getValue())); // pass
assertTrue("attributeName".equals(first.getKey())); // fail
}
Please have a look at this issue.
Thank you and kind regards Edgar
Issue Analytics
- State:
- Created 11 years ago
- Reactions:1
- Comments:21 (3 by maintainers)
Top Results From Across the Web
XML attribute becomes lower case when appending to DOM
This is happening because you are trying to add XML to the HTML DOM. HTML normalizes the case of element names, XML does...
Read more >Controlling XML Serialization Using Attributes - Microsoft Learn
Attributes can be used to control the XML serialization of an object or to create an alternate XML stream from the same set...
Read more >Extensible Markup Language (XML) 1.0 (Fifth Edition) - W3C
The function of the markup in an XML document is to describe its storage and logical structure and to associate attribute name-value pairs...
Read more >tidy - check, correct, and pretty-print HTML(5) files
Tidy reads HTML, XHTML, and XML files and writes cleaned-up markup. ... results in lower case attribute names, except for XML input, where...
Read more >TextView - Android Developers
android:inputMethod, If set, specifies that this TextView should use the specified input method (specified by fully-qualified class name).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This really is frustrating for an otherwise great library. Zazi seems to have provided a ready to use solution. Is there any reason why it has not been merged yet?
I have implemented a new feature ParseSettings, which allows the user to preserve tag and/or attribute name case at parse (and therefore output) time. For XML it defaults to preserving case, and lower case for HTML parsing.
https://github.com/jhy/jsoup/commit/e38b916ba1ebd3f5c00a6b6b8e77a4cdfea2800f
Thanks for everyone’s feedback and contributions.