public class XmlUtil
extends java.lang.Object
限定符和类型 | 类和说明 |
---|---|
static class |
XmlUtil.DHNode
封装系统dom Node节点,可确保因系统平台差异,编译出错仅为此文件
|
限定符和类型 | 字段和说明 |
---|---|
static int |
CDATA |
static int |
ELEMENT
Integer constant for elements
|
static int |
TEXT
Integer constant assigned to text nodes and events
|
构造器和说明 |
---|
XmlUtil() |
限定符和类型 | 方法和说明 |
---|---|
static void |
addChild(XmlUtil.DHNode pParent,
XmlUtil.DHNode pChild,
int type)
Description: 添加节点
|
static void |
attrFill2HashMap(java.util.HashMap<java.lang.String,java.lang.String> pTable,
XmlUtil.DHNode pElement)
Description: 把一个element的属性添加到一个HashMap里去
|
static java.lang.String |
elementToString(XmlUtil.DHNode pElement) |
static java.util.ArrayList<java.lang.String[]> |
getAttributes(XmlUtil.DHNode pElement)
Description: 得到属性集
|
static java.lang.String |
getAttributeValue(XmlUtil.DHNode pElement,
java.lang.String pAttributeName)
Description: 获取Element里指定属性的值
|
static int |
getAttributeValue(XmlUtil.DHNode pElement,
java.lang.String pAttributeName,
int pDefaultValue)
获取Element里指定属性的int类型值
|
static java.lang.String |
getAttributeValue(XmlUtil.DHNode pElement,
java.lang.String pAttributeName,
java.lang.String pDefaultValue)
Description: 获取Element里指定属性的值
|
static XmlUtil.DHNode |
getChild(XmlUtil.DHNode pElement,
int pIndex)
Description: 得到Element 子节点(Node)
|
static XmlUtil.DHNode |
getElement(XmlUtil.DHNode pElement,
java.lang.String pNodeName)
Description: 根据制定的element名得到Element,如果有多个Element,则返回第一个
|
static XmlUtil.DHNode |
getElementDocument(XmlUtil.DHNode pElement)
Description: 得到element所属的document
|
static java.lang.String |
getElementName(XmlUtil.DHNode pElement)
Description: 得到Element的节点名
|
static java.util.ArrayList<XmlUtil.DHNode> |
getElements(XmlUtil.DHNode pElement,
java.lang.String pNodeName)
Description: 获取源Element的子节点为pNodeName的所有节点(一级子节点)
|
static int |
getNodeType(XmlUtil.DHNode pElement,
int pIndex)
Description: 获取节点的类型
|
static XmlUtil.DHNode |
getRootElement(XmlUtil.DHNode pDocument) |
static java.lang.String |
getText(XmlUtil.DHNode pElement)
Description: 得到Element里文本的内容
|
static java.lang.String |
getTextValue(XmlUtil.DHNode pText)
Description: 得到Text对象的值
|
static boolean |
isElement(java.lang.Object pElement)
Description: 判断传入的对象是否是Element类型
|
static boolean |
isText(XmlUtil.DHNode pText)
Description: 判断传入的对象是否是Text类型,
|
static XmlUtil.DHNode |
newDocument()
Description:
|
static XmlUtil.DHNode |
newElement(XmlUtil.DHNode pDocument,
java.lang.String pName)
Description: 构造一个节点名为pName的element
|
static void |
removeAttribute(XmlUtil.DHNode pElement,
java.lang.String name)
删除节点的某属性
|
static void |
removeChild(XmlUtil.DHNode pParent,
int pIndex)
Description: 删除pParent里指定序号的节点
|
static void |
removeChild(XmlUtil.DHNode pParent,
XmlUtil.DHNode pChild)
删除parentEle父节点中的指定child子节点
Description:
|
static void |
setAttributeValue(XmlUtil.DHNode pElement,
java.lang.String pName,
java.lang.String pValue)
Description: 设置element的属性
|
static void |
setText(XmlUtil.DHNode pElement,
java.lang.String pText)
设置pElement的text值
Description:
|
static XmlUtil.DHNode |
XML_Parser(java.io.InputStream is)
Description: 从输入流解析得到一个Element
|
static XmlUtil.DHNode |
XML_ParserDocument(java.io.InputStream is)
Description: 从输入流解析得到一个Document
|
public static final int ELEMENT
public static final int TEXT
public static final int CDATA
public static java.lang.String getAttributeValue(XmlUtil.DHNode pElement, java.lang.String pAttributeName, java.lang.String pDefaultValue)
pElement
- pAttributeName
- 属性名pDefaultValue
- 当取得的vaule为null时,则返回pDefaultValuepublic static int getAttributeValue(XmlUtil.DHNode pElement, java.lang.String pAttributeName, int pDefaultValue)
pElement
- pAttributeName
- 属性名pDefaultValue
- 当取得的vaule为null时,则返回pDefaultValueModifiedLog:
Log ID: 1.0 (Log编号 依次递增) Modified By: yanglei Email:yanglei@dcloud.io at 2011-7-26 下午12:25:17
public static java.lang.String getAttributeValue(XmlUtil.DHNode pElement, java.lang.String pAttributeName)
pElement
- 需要获取值的ElementpAttributeName
- 属性名public static java.lang.String getText(XmlUtil.DHNode pElement)
pElement
- public static void setText(XmlUtil.DHNode pElement, java.lang.String pText)
pElement
- public static java.lang.String getElementName(XmlUtil.DHNode pElement)
pElement
- public static java.util.ArrayList<XmlUtil.DHNode> getElements(XmlUtil.DHNode pElement, java.lang.String pNodeName)
pElement
- 源ElementpNodeName
- 节点名public static XmlUtil.DHNode getElement(XmlUtil.DHNode pElement, java.lang.String pNodeName)
pElement
- 源ElementpNodeName
- 节点名public static XmlUtil.DHNode getChild(XmlUtil.DHNode pElement, int pIndex)
pElement
- public static int getNodeType(XmlUtil.DHNode pElement, int pIndex)
pElement
- pIndex
- public static boolean isElement(java.lang.Object pElement)
pElement
- public static XmlUtil.DHNode newElement(XmlUtil.DHNode pDocument, java.lang.String pName)
pName
- 节点名public static void addChild(XmlUtil.DHNode pParent, XmlUtil.DHNode pChild, int type)
pParent
- 父节点pChild
- 子节点type
- 添加的节点的类型,分为ELEMENT,TEXT两类public static void removeChild(XmlUtil.DHNode pParent, int pIndex)
pChild
- pIndex
- public static void removeChild(XmlUtil.DHNode pParent, XmlUtil.DHNode pChild)
pParent
- pChild
- public static void setAttributeValue(XmlUtil.DHNode pElement, java.lang.String pName, java.lang.String pValue)
pElement
- 要设置的elementpName
- 属性名pValue
- 属性值public static XmlUtil.DHNode XML_Parser(java.io.InputStream is)
is
- 输入流public static XmlUtil.DHNode getRootElement(XmlUtil.DHNode pDocument)
public static java.util.ArrayList<java.lang.String[]> getAttributes(XmlUtil.DHNode pElement)
pElement
- 从pElement得到属性集public static void attrFill2HashMap(java.util.HashMap<java.lang.String,java.lang.String> pTable, XmlUtil.DHNode pElement)
pTable
- 需要填充的hashtablepElement
- 获取属性的elementpublic static XmlUtil.DHNode newDocument()
public static boolean isText(XmlUtil.DHNode pText)
pText
- public static java.lang.String getTextValue(XmlUtil.DHNode pText)
pText
- Text对象public static XmlUtil.DHNode XML_ParserDocument(java.io.InputStream is)
is
- public static XmlUtil.DHNode getElementDocument(XmlUtil.DHNode pElement)
pElement
- public static void removeAttribute(XmlUtil.DHNode pElement, java.lang.String name)
pElement
- name
- public static java.lang.String elementToString(XmlUtil.DHNode pElement)