Package org.astrogrid.samp.xmlrpc.internal

# Class XmlUtils

java.lang.Object
org.astrogrid.samp.xmlrpc.internal.XmlUtils

public class XmlUtils extends Object
Utilities for XML manipulations required by SAMP/XML-RPC.

Since:
  26 Aug 2008
Author:
  Mark Taylor

## Method Summary

Modifier and Type
Method
Description
`static Element`
`getChild(Node parent)`
Returns the single element child of a DOM node.
`static Element`
`getChild(Node parent, String tagName)`
Returns the single child element of a DOM node, which has a given known name.
`static Element[]`
`getChildren(Node parent)`
Returns an array of all the Element children of a DOM node.
`static String`
`getTextContent(Element el)`
Returns the text content of an element as a string.
`static Object`
`parseSampValue(Element valueEl)`
Returns the content of a DOM element representing a `value` element of an XML-RPC document.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### getChildren

public static Element[] getChildren(Node parent)
Returns an array of all the Element children of a DOM node.

Parameters:
  `parent` - parent node
Returns:
  children array

### getChild

public static Element getChild(Node parent) throws org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException
Returns the single element child of a DOM node.

Parameters:
  `parent` - parent node
Returns:
  sole child element
Throws:
  `org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException` - if there is not exactly one child per element

### getChild

public static Element getChild(Node parent, String tagName) throws org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException
Returns the single child element of a DOM node, which has a given known name.

Parameters:
  `parent` - parent node
  `tagName` - child node name
Returns:
  sole child element with name `tagName`
Throws:
  `org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException` - if there is not exactly one child element or if it does not have name `tagName`

### getTextContent

public static String getTextContent(Element el) throws org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException
Returns the text content of an element as a string.

Parameters:
  `el` - parent node
Returns:
  text content
Throws:
  `org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException` - if content is not just text

### parseSampValue

public static Object parseSampValue(Element valueEl) throws org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException
Returns the content of a DOM element representing a `value` element of an XML-RPC document. Note that some content which would be legal in XML-RPC, but is not legal in SAMP, may result in an exception.

Parameters:
  `valueEl` - value element
Returns:
  SAMP-friendly object (string, list or map)
Throws:
  `org.astrogrid.samp.xmlrpc.internal.XmlRpcFormatException`