本文整理汇总了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);
}