com.jayway.maven.plugins.android.common.XmlHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-maven-plugin Show documentation
Show all versions of android-maven-plugin Show documentation
Maven Plugin for Android Development
package com.jayway.maven.plugins.android.common;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Yet another helper class for dealing with XML.
*/
public class XmlHelper
{
public static void removeDirectChildren( Node parent )
{
NodeList childNodes = parent.getChildNodes();
while ( childNodes.getLength() > 0 )
{
parent.removeChild( childNodes.item( 0 ) );
}
}
public static Element getOrCreateElement( Document doc, Element manifestElement, String elementName )
{
NodeList nodeList = manifestElement.getElementsByTagName( elementName );
Element element = null;
if ( nodeList.getLength() == 0 )
{
element = doc.createElement( elementName );
manifestElement.appendChild( element );
}
else
{
element = ( Element ) nodeList.item( 0 );
}
return element;
}
}