本文整理匯總了Java中org.w3c.dom.NamedNodeMap.removeNamedItem方法的典型用法代碼示例。如果您正苦於以下問題:Java NamedNodeMap.removeNamedItem方法的具體用法?Java NamedNodeMap.removeNamedItem怎麽用?Java NamedNodeMap.removeNamedItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.NamedNodeMap
的用法示例。
在下文中一共展示了NamedNodeMap.removeNamedItem方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeApplicationDebugTag
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
* Removes "debug" tag from file
*
* @param file AndroidManifest file
* @throws AndrolibException
*/
public static void removeApplicationDebugTag(File file) throws AndrolibException {
if (file.exists()) {
try {
Document doc = loadDocument(file);
Node application = doc.getElementsByTagName("application").item(0);
// load attr
NamedNodeMap attr = application.getAttributes();
Node debugAttr = attr.getNamedItem("android:debuggable");
// remove application:debuggable
if (debugAttr != null) {
attr.removeNamedItem("android:debuggable");
}
saveDocument(file, doc);
} catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
}
}
}
示例2: removeManifestVersions
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
* Removes attributes like "versionCode" and "versionName" from file.
*
* @param file File representing AndroidManifest.xml
* @throws AndrolibException
*/
public static void removeManifestVersions(File file) throws AndrolibException {
if (file.exists()) {
try {
Document doc = loadDocument(file);
Node manifest = doc.getFirstChild();
NamedNodeMap attr = manifest.getAttributes();
Node vCode = attr.getNamedItem("android:versionCode");
Node vName = attr.getNamedItem("android:versionName");
if (vCode != null) {
attr.removeNamedItem("android:versionCode");
}
if (vName != null) {
attr.removeNamedItem("android:versionName");
}
saveDocument(file, doc);
} catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) {
}
}
}
示例3: changeDocument
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public void changeDocument(Node componentNode)
{
NamedNodeMap attributes = componentNode.getAttributes();
if (attributes != null)
{
// remove the attribute
if (_attributeValueString == null)
attributes.removeNamedItem(_attributeName);
else
{
((Element)componentNode).setAttribute(_attributeName,
_attributeValueString);
}
}
}
示例4: updateNamespace
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
/**
* Updates the namespace of a given node (and its children) to work in a given document
* @param node the node to update
* @param document the new document
*/
private static void updateNamespace(Node node, Document document) {
// first process this node
processSingleNodeNamespace(node, document);
// then its attributes
NamedNodeMap attributes = node.getAttributes();
if (attributes != null) {
for (int i = 0, n = attributes.getLength(); i < n; i++) {
Node attribute = attributes.item(i);
if (!processSingleNodeNamespace(attribute, document)) {
String nsUri = attribute.getNamespaceURI();
if (nsUri != null) {
attributes.removeNamedItemNS(nsUri, attribute.getLocalName());
} else {
attributes.removeNamedItem(attribute.getLocalName());
}
}
}
}
// then do it for the children nodes.
NodeList children = node.getChildNodes();
if (children != null) {
for (int i = 0, n = children.getLength(); i < n; i++) {
Node child = children.item(i);
if (child != null) {
updateNamespace(child, document);
}
}
}
}
示例5: removeAttribute
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
public static void removeAttribute( Node node, String attName ) {
NamedNodeMap attributes=node.getAttributes();
attributes.removeNamedItem(attName);
}
示例6: removeAttribute
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
public static void removeAttribute( Node node, String attName ) {
NamedNodeMap attributes=node.getAttributes();
attributes.removeNamedItem(attName);
}
示例7: getAllAttributesFrom
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
protected static Iterator<Name> getAllAttributesFrom(final Element element) {
final NamedNodeMap attributes = element.getAttributes();
return new Iterator<Name>() {
int attributesLength = attributes.getLength();
int attributeIndex = 0;
String currentName;
@Override
public boolean hasNext() {
return attributeIndex < attributesLength;
}
@Override
public Name next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Node current = attributes.item(attributeIndex++);
currentName = current.getNodeName();
String prefix = NameImpl.getPrefixFromTagName(currentName);
if (prefix.length() == 0) {
return NameImpl.createFromUnqualifiedName(currentName);
} else {
Name attributeName =
NameImpl.createFromQualifiedName(
currentName,
current.getNamespaceURI());
return attributeName;
}
}
@Override
public void remove() {
if (currentName == null) {
throw new IllegalStateException();
}
attributes.removeNamedItem(currentName);
}
};
}
示例8: removeAttribute
import org.w3c.dom.NamedNodeMap; //導入方法依賴的package包/類
public static void removeAttribute(Node node, String attName) {
NamedNodeMap attributes = node.getAttributes();
attributes.removeNamedItem(attName);
}