XPath 1.0 queries on JAXB objects?

前端 未结 2 718
萌比男神i
萌比男神i 2020-12-29 14:15

JAXB has been great, a real timesaver, but it\'s still really time consuming to traverse the resulting object trees; almost as bad as working directly with the DOM.

2条回答
  •  萌比男神i
    2020-12-29 14:33

    Not directly, no. However, you can use Apache Commons Jxpath, which allows you to run XPath queries across arbitrary object graphs, not just JAXB-bound ones. It can be run in "lenient" mode, which is tolerant of nulls.

    Extremely handy for replacing those NPE-prone graph navigations.

提交回复
热议问题