1 package com.simpligility.maven.plugins.android.common;
2
3 import org.w3c.dom.Document;
4 import org.w3c.dom.Element;
5 import org.w3c.dom.Node;
6 import org.w3c.dom.NodeList;
7
8
9
10
11 public class XmlHelper
12 {
13
14 public static void removeDirectChildren( Node parent )
15 {
16 NodeList childNodes = parent.getChildNodes();
17 while ( childNodes.getLength() > 0 )
18 {
19 parent.removeChild( childNodes.item( 0 ) );
20 }
21 }
22
23 public static Element getOrCreateElement( Document doc, Element manifestElement, String elementName )
24 {
25 NodeList nodeList = manifestElement.getElementsByTagName( elementName );
26 Element element = null;
27 if ( nodeList.getLength() == 0 )
28 {
29 element = doc.createElement( elementName );
30 manifestElement.appendChild( element );
31 }
32 else
33 {
34 element = ( Element ) nodeList.item( 0 );
35 }
36 return element;
37 }
38 }