question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XML Attribute Names are converted to lower case, where they should stay as in the original input

See original GitHub issue

Hello,

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:closed
  • Created 11 years ago
  • Reactions:1
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
robencommented, Jun 13, 2016

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?

3reactions
jhycommented, Aug 10, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found