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

XmlFlattener doesn't work with Attribute nodes #25

Closed
danduff opened this issue Sep 20, 2017 · 1 comment
Closed

XmlFlattener doesn't work with Attribute nodes #25

danduff opened this issue Sep 20, 2017 · 1 comment
Labels

Comments

@danduff
Copy link

danduff commented Sep 20, 2017

The XMLFlattener only allows access to Element nodes and not Attribute nodes.

e.g.
Element nodes successfully work with an XPATH of /element
<element>value</element>

Attribute nodes do no work with an XPATH of /attribute[@name='key']/@value
<attribute name='key' value='value' />

I've tried a fix for this by modifying isXmlLeafNode() to check for either ELEMENT_NODE or ATTRIBUTE_NODE which resolved the problem I had.

return node != null && (node.getNodeType() == Node.ELEMENT_NODE || node.getNodeType() == Node.ATTRIBUTE_NODE) && node.getChildNodes().getLength() == 1 && node.getFirstChild().getNodeType() == Node.TEXT_NODE;

tomasbjerre added a commit that referenced this issue Sep 20, 2017
@tomasbjerre
Copy link
Contributor

Released in 1.20 now. Open issue again if not working.

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

No branches or pull requests

2 participants