Class XMLToKeyValuePairs

  • public final class XMLToKeyValuePairs
    extends Object
    Used to serialize Node from a DOM tree to an Object (mainly KeyValuePairs). This class cannot handle adjacent text nodes, so the DOM tree should be normalized first. Nodes that have child elements or mixed content with get transformed to KeyValuePairs, String only nodes with an xsi:type attribute get deserialized to the given type, String otherwise. Empty nodes will return null.
    Uwe Schindler
    See Also:
    • Field Detail


        public static final String ATTRIBUTE_ELEMENT_PREFIX
        If an element has a local name with this prefix, it is converted to a JSON attribute, prefixed by @.
        See Also:
        Constant Field Values
    • Constructor Detail

      • XMLToKeyValuePairs

        public XMLToKeyValuePairs​(boolean serializeAttributes)
                           throws jakarta.xml.bind.JAXBException
    • Method Detail

      • convertChilds

        public Object convertChilds​(Node parentNode)
                             throws jakarta.xml.bind.JAXBException
        Convert all children of a node: It first checks if all child nodes are text-only, in that case the whole node is returned as String (using Node.getTextContent(). In all other cases its starts a new JSON object and converts every contained node. Empty nodes will be returned as null.