Last change
on this file since 6498 was 6344, checked in by cs025, 20 years ago |
Improvements/changes to handling of HTML tidying
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
974 bytes
|
Line | |
---|
1 | package org.greenstone.gsdl3.gs3build.util;
|
---|
2 |
|
---|
3 | import org.w3c.dom.Document;
|
---|
4 | import org.w3c.dom.Element;
|
---|
5 | import org.w3c.dom.NamedNodeMap;
|
---|
6 | import org.w3c.dom.Node;
|
---|
7 | import org.w3c.dom.NodeList;
|
---|
8 | import org.w3c.dom.Text;
|
---|
9 |
|
---|
10 | public class DOMUtils
|
---|
11 | {
|
---|
12 | public static String getNodeAttribute(Node node, String attribute)
|
---|
13 | {
|
---|
14 | NamedNodeMap atts = node.getAttributes();
|
---|
15 | if (atts == null) {
|
---|
16 | return null;
|
---|
17 | }
|
---|
18 | Node attributeNode = atts.getNamedItem(attribute);
|
---|
19 | if (attributeNode == null) {
|
---|
20 | return null;
|
---|
21 | }
|
---|
22 | return attributeNode.getNodeValue();
|
---|
23 | }
|
---|
24 |
|
---|
25 | public static String getNodeChildText(Node node)
|
---|
26 | {
|
---|
27 | StringBuffer fieldName = new StringBuffer();
|
---|
28 |
|
---|
29 | NodeList fieldChildren = node.getChildNodes();
|
---|
30 | for (int f = 0; f < fieldChildren.getLength(); f ++) {
|
---|
31 | if (fieldChildren.item(f).getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
|
---|
32 | fieldName.append(fieldChildren.item(f).getNodeValue());
|
---|
33 | }
|
---|
34 | }
|
---|
35 | return fieldName.toString();
|
---|
36 | }
|
---|
37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.