Package PamUtils

Class XMLUtils

java.lang.Object
PamUtils.XMLUtils

public class XMLUtils extends Object
  • Constructor Details

    • XMLUtils

      public XMLUtils()
  • Method Details

    • getStringFromDocument

      public static String getStringFromDocument(Document doc)
      Convert an xml document to a String.
      Parameters:
      doc - xml document
    • getDocumentFromString

      public static Document getDocumentFromString(String xmlString)
      Convert a string back into an XML document.
      Parameters:
      xmlString - String
      Returns:
      XML Document, or null if there was an error
    • getIntegerValue

      public static Integer getIntegerValue(Element el, String name)
      Get an integer attribute from an Element
      Parameters:
      el - XML Element
      name - Attribute name
      Returns:
      null if not a number
    • getDoubleValue

      public static Double getDoubleValue(Element el, String name)
      Get a Double attribute from an Element
      Parameters:
      el - XML Element
      name - Attribute name
      Returns:
      null if not a number
    • createBlankDoc

      public static Document createBlankDoc()
      Creates a blank Document object, or returns null if there was an error
      Returns:
    • createDocument

      public static Document createDocument(String xmlFileName)
      Create an xml document from an xml file.
      Parameters:
      xmlFileName - xml file name
      Returns:
      document
    • createDocument

      public static Document createDocument(File xmlFile)
      Create an xml document from an xml file.
      Parameters:
      xmlFile - xml file
      Returns:
      document
    • writeToFile

      public static void writeToFile(Document doc, File outFile) throws IOException
      Write to the given file.
      Parameters:
      doc - xml document
      outFile - file
      Throws:
      IOException
    • getAsString

      public static String getAsString(Document doc)
      Get the xml document as a String.
      Parameters:
      doc - xml document
      Returns:
      xml content as a a string.