1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
121 if(children.getLength() >= 1) |
121 if(children.getLength() >= 1) |
122 return (Element)children.item(0); |
122 return (Element)children.item(0); |
123 return null; |
123 return null; |
124 } |
124 } |
125 |
125 |
126 // these implementations look wrong to me, since getElementsByTagName returns |
|
127 // all the elements in descendants, not just children. |
|
128 // |
|
129 // public static Element[] getChildElements(Element parent, QName qname) { |
|
130 // NodeList children = parent.getElementsByTagNameNS(qname.uri, qname.localpart); |
|
131 // return getElements(children); |
|
132 // } |
|
133 // |
|
134 // public static Element[] getChildElements(Element parent, String namespaceURI, |
|
135 // String localName) { |
|
136 // NodeList children = parent.getElementsByTagNameNS(namespaceURI, localName); |
|
137 // return getElements(children); |
|
138 // } |
|
139 // |
|
140 // public static Element[] getChildElements(Element parent, String name) { |
|
141 // NodeList children = parent.getElementsByTagName(name); |
|
142 // return getElements(children); |
|
143 // } |
|
144 |
|
145 public static Element[] getElements(NodeList children) { |
126 public static Element[] getElements(NodeList children) { |
146 Element[] elements = null; |
127 Element[] elements = null; |
147 int len = 0; |
128 int len = 0; |
148 for (int i = 0; i < children.getLength(); ++i) { |
129 for (int i = 0; i < children.getLength(); ++i) { |
149 if (elements == null) |
130 if (elements == null) |