本文整理汇总了Java中com.google.gwt.xml.client.Document.getElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getElementsByTagName方法的具体用法?Java Document.getElementsByTagName怎么用?Java Document.getElementsByTagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.xml.client.Document
的用法示例。
在下文中一共展示了Document.getElementsByTagName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixLinks
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
/**
* Fix links relative to xml file
*
* @param tagName tag name
* @param attrName attribute name with link
*/
private void fixLinks(Document document, String baseUrl, String tagName, String attrName) {
NodeList nodes = document.getElementsByTagName(tagName);
for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
String link = element.getAttribute(attrName);
if (link != null && !link.startsWith("http")) {
element.setAttribute(attrName, baseUrl + link);
}
// Links open in new window
if (tagName.compareTo("a") == 0) {
element.setAttribute("target", "_blank");
}
}
}
示例2: parseXmlDocumentAsBook
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
private Book[] parseXmlDocumentAsBook(Document xml) {
final NodeList idNodes = xml.getElementsByTagName("id");
final NodeList titleNodes = xml.getElementsByTagName("title");
final NodeList authorNodes = xml.getElementsByTagName("author");
int length = idNodes.getLength();
Book[] books = new Book[length];
for (int i = 0; i < length; i++) {
String id = ((Text) idNodes.item(i).getFirstChild()).getData();
String title = ((Text) titleNodes.item(i).getFirstChild()).getData();
String author = ((Text) authorNodes.item(i).getFirstChild()).getData();
books[i] = new Book(Integer.valueOf(id), title, author);
}
return books;
}
示例3: parseXmlDocumentAsBook
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
private Book[] parseXmlDocumentAsBook(Document xml) {
final NodeList idNodes = xml.getElementsByTagName("id");
final NodeList titleNodes = xml.getElementsByTagName("title");
final NodeList authorNodes = xml.getElementsByTagName("author");
final NodeList publicationDateNodes = xml.getElementsByTagName("publicationDate");
int length = idNodes.getLength();
Book[] books = new Book[length];
for (int i = 0; i < length; i++) {
String id = ((Text) idNodes.item(i).getFirstChild()).getData();
String title = ((Text) titleNodes.item(i).getFirstChild()).getData();
String author = ((Text) authorNodes.item(i).getFirstChild()).getData();
String publicationDate = ((Text) publicationDateNodes.item(i).getFirstChild()).getData();
books[i] = new Book(Integer.valueOf(id), title, author, new Date(Long.valueOf(publicationDate)));
}
return books;
}
示例4: createElement
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
private Entry createElement(String response, int index) {
Document document = xmlParser.parse(response);
NodeList wordElements = document.getElementsByTagName(TAG_NAME);
Element word = (Element) wordElements.item(index);
String entry = fetchValue(word, ENTRY_ATTR_NAME);
String entryDescription = fetchValue(word, ENTRY_DESCRIPTION_ATTR_NAME);
String type = fetchValue(word, TYPE_ATTR_NAME);
String entryExample = fetchValue(word, ENTRY_EXAMPLE_ATTR_NAME);
String entrySound = fetchValue(word, ENTRY_SOUND_ATTR_NAME);
String entryExampleSound = fetchValue(word, ENTRY_EXAMPLE_SOUND_ATTR_NAME);
String label = fetchValue(word, ENTRY_LABEL_ATTR_NAME);
return new Entry(entry, entryDescription, type, entryExample, entrySound, entryExampleSound, label);
}
示例5: prepareSkin
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
private void prepareSkin(XmlData data) {
Document document = data.getDocument();
skinData = data;
styleDeclaration = new StyleLinkDeclaration(document.getElementsByTagName("styleDeclaration"), data.getBaseURL());
metaDescriptionManager.processDocument(document);
loadListener.onSkinLoad();
}
示例6: getElementValue
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
private String getElementValue(String element, Document doc) {
NodeList results_y = doc.getElementsByTagName(element);
String value = null;
for (int n = 0; n < results_y.getLength(); n++) {
if (results_y.item(n) instanceof Element) {
Element result = (Element) results_y.item(n);
Node text = result.getFirstChild();
if (text instanceof Text) {
Text t = (Text) text;
value = t.getData();
}
}
}
return value;
}
示例7: isExecutionCalendarGIDefined
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
private Boolean isExecutionCalendarGIDefined(String jobDescriptor) {
Document dom = XMLParser.parse(jobDescriptor);
Boolean exists = false;
Boolean executionCalendarDefined = false;
NodeList genericInfo = dom.getElementsByTagName("genericInformation");
// check if the job has genericInformation or not
if (genericInfo != null && genericInfo.getLength() > 0) {
// get the first item
Node root = genericInfo.item(0);
NodeList list = root.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeName().equals("info") && node.hasAttributes()) {
NamedNodeMap attributes = node.getAttributes();
for (int j = 0; j < attributes.getLength(); j++) {
Node attribute = attributes.item(j);
if (attribute.getNodeType() == Node.ATTRIBUTE_NODE && attribute.getNodeName().equals("name") &&
attribute.getNodeValue().equalsIgnoreCase("execution_calendars")) {
exists = true;
}
if (isAttributeExecCalendarValueDefined(attribute, "value") && exists) {
executionCalendarDefined = true;
if (!attribute.getNodeValue().isEmpty())
isExecCalendarValueNull = false;
}
}
}
}
}
return executionCalendarDefined;
}
示例8: parseServiceDataXml
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
public static void parseServiceDataXml(String serviceDataXmlString) {
errorStatuses.clear();
schemaLocations.clear();
defaultNamespace.clear();
otherNamespaces.clear();
Document response = XMLParser.parse(serviceDataXmlString);
NodeList namespaces = response.getElementsByTagName("namespace");
for (int i = 0; i < namespaces.getLength(); i++) {
Node namespace = namespaces.item(i);
if (namespace.hasChildNodes()) {
String namespaceString = namespace.getFirstChild().getNodeValue();
if ((!otherNamespaces.contains(namespaceString)) &&
(!namespaceString.equals(WadlXml.xmlns_xsd)) &&
(!namespaceString.equals(WadlXml.xmlns_xsi))) {
otherNamespaces.add(namespaceString);
}
}
}
NodeList requests = response.getElementsByTagName("requestData");
for (int i = 0; i < requests.getLength(); i++) {
Node request = requests.item(i);
NodeList requestChildren = request.getChildNodes();
for (int j = 0; j < requestChildren.getLength(); j++) {
Node requestChild = requestChildren.item(j);
if (requestChild.getNodeName().equals("validRequest")) {
treatValidRequests(requestChild);
}
else if (requestChild.getNodeName().equals("erroneousRequests")) {
treatErroneousRequests(requestChild);
}
}
}
show();
}
示例9: onSubmitComplete
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
public void onSubmitComplete(SubmitCompleteEvent event) {
updateStatusTimer.cancel();
onSubmitComplete = true;
serverResponse = event.getResults();
if (serverResponse != null) {
serverResponse = serverResponse.replaceFirst(".*" + TAG_MSG_START + "([\\s\\S]*?)" + TAG_MSG_END + ".*", "$1");
serverResponse = serverResponse.replace(TAG_MSG_LT, "<").replace(TAG_MSG_GT, ">").replace("<", "<").replaceAll(">", ">");
}
log("onSubmitComplete: " + serverResponse, null);
try {
// Parse the xml and extract serverInfo
Document doc = XMLParser.parse(serverResponse);
serverInfo.setMessage(Utils.getXmlNodeValue(doc, TAG_MESSAGE));
serverInfo.setField(Utils.getXmlNodeValue(doc, TAG_FIELD));
NodeList list = doc.getElementsByTagName(TAG_FILE);
for (int i = 0; i < list.getLength(); i++) {
UploadedInfo info = new UploadedInfo();
info.setName(doc.getElementsByTagName(TAG_NAME).item(i).getFirstChild().getNodeValue());
info.setCtype(doc.getElementsByTagName(TAG_CTYPE).item(i).getFirstChild().getNodeValue());
String size = doc.getElementsByTagName(TAG_SIZE).item(i).getFirstChild().getNodeValue();
if (size != null) {
info.setSize(Integer.parseInt(size));
}
serverInfo.add(info);
}
// If the server response is a valid xml
parseAjaxResponse(serverResponse);
} catch (Exception e) {
log("onSubmitComplete exception parsing response: ", e);
// Otherwise force an ajax request so as we have not to wait to the timer schedule
updateStatusTimer.run();
}
}
示例10: getXmlNodeValue
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
/**
* return the text content of a tag in a xml document.
*/
public static String getXmlNodeValue(Document doc, String tag) {
if (doc == null) {
return null;
}
NodeList list = doc.getElementsByTagName(tag);
if (list.getLength() == 0) {
return null;
}
return getXmlNodeValue(list, tag);
}
示例11: getParentNodesForFeedbacks
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
@Override
protected NodeList getParentNodesForFeedbacks(Document xmlDocument) {
return xmlDocument.getElementsByTagName(EmpiriaTagConstants.NAME_SIMPLE_CHOICE);
}
示例12: readVars
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
/**
* @param jobDescriptor an XML job descriptor as a string
* @return the name/value of all <variables><variable name value> elements
*/
private Map<String, JobVariable> readVars(String jobDescriptor) {
/*
* this will fail if someday the XML schema gets another <variable> tag
* elsewhere
*/
Document dom = XMLParser.parse(jobDescriptor);
NodeList variables = dom.getElementsByTagName("variable");
Map<String, JobVariable> ret = new LinkedHashMap<>();
if (variables.getLength() > 0) {
for (int i = 0; i < variables.getLength(); i++) {
Node variableNode = variables.item(i);
if (variableNode != null && !isTaskVariableElement(variableNode)) {
NamedNodeMap attrs = variableNode.getAttributes();
try {
if (attrs != null && variableNode.hasAttributes()) {
String name = null;
String value = null;
String model = null;
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equals("name")) {
name = attr.getNodeValue();
}
if (attr.getNodeName().equals("value")) {
value = attr.getNodeValue();
}
if (attr.getNodeName().equals("model")) {
model = attr.getNodeValue();
}
}
if (name != null && value != null) {
if (!name.matches("[A-Za-z0-9._]+")) {
// this won't necessarily be a problem at
// job submission,
// but it definitely will be here in the
// client; don't bother
continue;
}
ret.put(name, new JobVariable(name, value, model));
}
}
} catch (JavaScriptException t) {
// Node.hasAttributes() throws if there are no
// attributes... (GWT 2.1.0)
}
}
}
}
return ret;
}
示例13: read
import com.google.gwt.xml.client.Document; //导入方法依赖的package包/类
public ListLoadResult read(C loadConfig, Object data) {
Document doc = XMLParser.parse((String) data);
NodeList list = doc.getElementsByTagName(modelType.recordName);
ArrayList<ModelData> records = new ArrayList<ModelData>();
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
Element elem = (Element) node;
ModelData model = newModelInstance();
for (int j = 0; j < modelType.getFieldCount(); j++) {
DataField field = modelType.getField(j);
String map = field.map != null ? field.map : field.name;
// Fix to allow not existsing elements.
try {
String v = getValue(elem, map);
model.set(field.name, v);
} catch (Throwable t) {
// Ignore.
}
}
records.add(model);
}
int totalCount = records.size();
Node root = doc.getElementsByTagName(modelType.root).item(0);
if (root != null && modelType.totalName != null) {
Node totalNode = root.getAttributes().getNamedItem(modelType.totalName);
if (totalNode != null) {
String sTot = totalNode.getNodeValue();
totalCount = Integer.parseInt(sTot);
}
}
ListLoadResult result = newLoadResult(loadConfig, records);
if (result instanceof PagingLoadResult) {
PagingLoadResult r = (PagingLoadResult) result;
r.setTotalLength(totalCount);
}
return result;
}