Class XmlUtil

java.lang.Object
ucar.unidata.xml.XmlUtil
edu.wisc.ssec.mcidasv.util.XmlUtil

public abstract class XmlUtil extends XmlUtil
A collection of utilities for XML.
  • Constructor Details

  • Method Details

    • printNode

      public static void printNode(Node parent)
      Print all the attributes of the given node
      Parameters:
      parent - Node whose attributes will be printed.
    • findDescendantNamesWithSeparator

      public static List<String> findDescendantNamesWithSeparator(Node parent, String tag, String separator)
      Find all of the descendant elements of the given parent Node whose tag name equals the given tag.
      Parameters:
      parent - Root of the XML DOM tree to search.
      tag - Tag name to match.
      separator - String that separates tags into components.
      Returns:
      List of descendants that match the given tag.
    • findDescendantNamesWithSeparator

      private static void findDescendantNamesWithSeparator(Node parent, String tag, String descendants, String separator, List<String> found)
      Find all of the descendant elements of the given parent Node whose tag name equals the given tag.
      Parameters:
      parent - Root of the XML DOM tree to search.
      tag - Tag name to match.
      descendants - Descendant elements.
      separator - String separating tag components (also in descendants).
      found - List of descendants that match the given tag.
    • getElementAtNamedPath

      public static Element getElementAtNamedPath(Node parent, List<String> nameList)
      Find the element described by nameList (path).
      Parameters:
      parent - Node at which the search should begin.
      nameList - List of node names to search for (think xpath).
      Returns:
      Element described by the given path, or null if there was a problem.
    • makeElementAtNamedPath

      public static Element makeElementAtNamedPath(Node parent, List<String> nameList, String tagName)
      Make the element described by nameList (path).
      Parameters:
      parent - Node at which the search should begin.
      nameList - List of node names to search for (think xpath).
      tagName - Tag name to locate.
      Returns:
      Element described by the given path, or null if there was a problem.
    • getMakeElementAtNamedPath

      public static Element getMakeElementAtNamedPath(Node parent, List<String> nameList, String tagName, boolean makeNew)
      Find the element described by nameList (path).
      Parameters:
      parent - Node at which the search should begin.
      nameList - List of node names to search for (think xpath).
      tagName - Tag name to locate.
      makeNew - Whether or not a new Element should be created.
      Returns:
      Element described by the given path, or null if there was a problem.
    • stripNonValidXMLCharacters

      This method ensures that the output String has only valid XML unicode characters as specified by the XML 1.0 standard.

      For reference, please see the standard. This method will return an empty String if the input is null or empty.

      Parameters:
      in - String whose non-valid characters we want to remove.
      Returns:
      The in String, stripped of non-valid characters.