当前位置: 首页>>代码示例>>Java>>正文


Java Document.getFirstChild方法代码示例

本文整理汇总了Java中org.w3c.dom.Document.getFirstChild方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getFirstChild方法的具体用法?Java Document.getFirstChild怎么用?Java Document.getFirstChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Document的用法示例。


在下文中一共展示了Document.getFirstChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadServerNames

import org.w3c.dom.Document; //导入方法依赖的package包/类
private void loadServerNames()
{
    try
    {
        File f = new File("config/other/servername.xml");
        Document doc = XMLDocumentFactory.getInstance().loadDocument(f);

        Node n = doc.getFirstChild();
        for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
        {
            if (d.getNodeName().equalsIgnoreCase("server"))
            {
                NamedNodeMap attrs = d.getAttributes();

                int id = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
                String name = attrs.getNamedItem("name").getNodeValue();

                _serverNames.put(id, name);
            }
        }
    }
    catch (Exception e)
    {
        _log.warning("GameServerTable: servername.xml could not be loaded.");
    }
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:27,代码来源:GameServerTable.java

示例2: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
protected void parseDocument(Document doc)
{
       for (Node n=doc.getFirstChild(); n != null; n = n.getNextSibling())
       {
           if ("list".equalsIgnoreCase(n.getNodeName()))
           {
               for (Node d=n.getFirstChild(); d != null; d = d.getNextSibling())
               {
                   if ("skill".equalsIgnoreCase(d.getNodeName()))
                   {
                       setCurrentSkill(new Skill());
                       parseSkill(d);
                       _skillsInFile.addAll(_currentSkill.skills);
                       resetTable();
                   }
               }
           }
           else if ("skill".equalsIgnoreCase(n.getNodeName()))
           {
               setCurrentSkill(new Skill());
               parseSkill(n);
               _skillsInFile.addAll(_currentSkill.skills);
           }
       }
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:27,代码来源:DocumentSkill.java

示例3: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("list".equalsIgnoreCase(n.getNodeName()))
		{
			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
			{
				if ("equipment".equalsIgnoreCase(d.getNodeName()))
				{
					parseEquipment(d);
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:18,代码来源:InitialEquipmentData.java

示例4: removeManifestVersions

import org.w3c.dom.Document; //导入方法依赖的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) {
        }
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:28,代码来源:ResXmlPatcher.java

示例5: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("list".equalsIgnoreCase(n.getNodeName()))
		{
			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
			{
				if ("category".equalsIgnoreCase(d.getNodeName()))
				{
					parseCategory(d);
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:18,代码来源:UIData.java

示例6: importFile

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Imports a file of unknown type.
 *
 * @param file The file to open
 * @param globalConfig The current global config
 * @param currentHistory history of the opened files to this point
 * @param importHybridSpecificationHandler A file handler (invoked if the file is a Specification)
 * @param importStvsRootModelHandler A file handler (invoked if the file is a Session)
 * @param codeConsumer A file handler (invoked if the file is a code file)
 * @throws IOException general io exception
 * @throws ImportException general importing exception
 */
public static void importFile(File file, GlobalConfig globalConfig, History currentHistory,
    ImportHybridSpecificationHandler importHybridSpecificationHandler,
    ImportStvsRootModelHandler importStvsRootModelHandler, ImportCodeHandler codeConsumer)
    throws IOException, ImportException {
  StringWriter writer = new StringWriter();
  byte[] byteArray = IOUtils.toByteArray(new FileInputStream(file));
  IOUtils.copy(new ByteArrayInputStream(byteArray), writer, "utf8");
  String inputString = writer.toString();
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  dbf.setNamespaceAware(true);
  try {
    Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(inputString)));
    if (doc != null && doc.getFirstChild() != null) {
      Node rootNode = doc.getFirstChild();
      switch (rootNode.getNodeName()) {
        case "session":
          importStvsRootModelHandler
              .accept(importSession(file, ImportFormat.XML, globalConfig, currentHistory));
          return;
        case "specification":
          importHybridSpecificationHandler.accept(importHybridSpec(file, ImportFormat.XML));
          return;
        default:
          codeConsumer.accept(importStCode(file));
          return;
      }
    }
  } catch (SAXException | ParserConfigurationException | ImportException e) {
    // ignore, because it might have been code
  }
  codeConsumer.accept(importStCode(file));
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:45,代码来源:ImporterFacade.java

示例7: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	for (Node listNode = doc.getFirstChild(); listNode != null; listNode = listNode.getNextSibling())
	{
		if ("list".equals(listNode.getNodeName()))
		{
			for (Node eventNode = listNode.getFirstChild(); eventNode != null; eventNode = eventNode.getNextSibling())
			{
				if ("event".equals(eventNode.getNodeName()))
				{
					parseEvent(eventNode);
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:18,代码来源:EventEngineData.java

示例8: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("list".equals(n.getNodeName()))
		{
			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
			{
				switch (d.getNodeName())
				{
					case "shortcuts":
					{
						parseShortcuts(d);
						break;
					}
					case "macros":
					{
						parseMacros(d);
						break;
					}
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:27,代码来源:InitialShortcutData.java

示例9: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("list".equals(n.getNodeName()))
		{
			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
			{
				if ("henna".equals(d.getNodeName()))
				{
					parseHenna(d);
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:18,代码来源:HennaData.java

示例10: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	final Node table = doc.getFirstChild();
	final NamedNodeMap tableAttr = table.getAttributes();
	
	MAX_LEVEL = (byte) (Byte.parseByte(tableAttr.getNamedItem("maxLevel").getNodeValue()) + 1);
	MAX_PET_LEVEL = (byte) (Byte.parseByte(tableAttr.getNamedItem("maxPetLevel").getNodeValue()) + 1);
	
	if (MAX_LEVEL > Config.PLAYER_MAXIMUM_LEVEL)
	{
		MAX_LEVEL = Config.PLAYER_MAXIMUM_LEVEL;
	}
	if (MAX_PET_LEVEL > MAX_LEVEL)
	{
		MAX_PET_LEVEL = MAX_LEVEL; // Pet level should not exceed owner level.
	}
	
	int maxLevel = 0;
	for (Node n = table.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("experience".equals(n.getNodeName()))
		{
			final NamedNodeMap attrs = n.getAttributes();
			maxLevel = parseInteger(attrs, "level");
			if (maxLevel > Config.PLAYER_MAXIMUM_LEVEL)
			{
				break;
			}
			_expTable.put(maxLevel, parseLong(attrs, "tolevel"));
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:34,代码来源:ExperienceData.java

示例11: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling())
	{
		if ("list".equalsIgnoreCase(node.getNodeName()))
		{
			for (Node list_node = node.getFirstChild(); list_node != null; list_node = list_node.getNextSibling())
			{
				if ("category".equalsIgnoreCase(list_node.getNodeName()))
				{
					final NamedNodeMap attrs = list_node.getAttributes();
					final CategoryType categoryType = CategoryType.findByName(attrs.getNamedItem("name").getNodeValue());
					if (categoryType == null)
					{
						LOGGER.warning(getClass().getSimpleName() + ": Can't find category by name: " + attrs.getNamedItem("name").getNodeValue());
						continue;
					}
					
					final Set<Integer> ids = new HashSet<>();
					for (Node category_node = list_node.getFirstChild(); category_node != null; category_node = category_node.getNextSibling())
					{
						if ("id".equalsIgnoreCase(category_node.getNodeName()))
						{
							ids.add(Integer.parseInt(category_node.getTextContent()));
						}
					}
					_categories.put(categoryType, ids);
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:34,代码来源:CategoryData.java

示例12: getSubjob

import org.w3c.dom.Document; //导入方法依赖的package包/类
private Document getSubjob(Document xmlDocument)
		throws FileNotFoundException {
	Node parentNode = xmlDocument.getFirstChild();
	String subjobComponentId, subjobComponentBatch;
	for (int i = 0; i < parentNode.getChildNodes().getLength(); i++) {
		if (isSubjobPresent(parentNode.getChildNodes().item(i))) {
			Node subjobNode = parentNode.getChildNodes().item(i);
			subjobComponentId = subjobNode.getAttributes().getNamedItem(ID)
					.getNodeValue();

			subjobComponentBatch = subjobNode.getAttributes().getNamedItem(
					BATCH) == null ? "0" : subjobNode.getAttributes()
					.getNamedItem(BATCH).getNodeValue();

			String subjobXml = EMPTY;
			subjobXml = readSubjob(subjobNode);
			if (!subjobXml.isEmpty()) {
				Document subjobXmlDocument = XmlUtilities
						.getXMLDocument(removeComments(subjobXml));
				subjobXmlDocument = getSubjob(subjobXmlDocument);
				xmlDocument = parseSubjob(xmlDocument, subjobXmlDocument,
						subjobComponentId, subjobComponentBatch);
			} else {
				throw new RuntimeException(
						"Subjob XML contents empty. Subjob ID: '"
								+ subjobComponentId + "'. Subjob path : " + subjobPath );
			}
		}
	}
	return xmlDocument;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:32,代码来源:ReadSubjob.java

示例13: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public final void parseDocument(Document doc, File f)
{
	StatsSet set;
	NamedNodeMap attrs;
	Node att;
	for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("list".equalsIgnoreCase(n.getNodeName()))
		{
			for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
			{
				if ("castle".equalsIgnoreCase(d.getNodeName()))
				{
					final int castleId = parseInteger(d.getAttributes(), "id");
					for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
					{
						if ("crop".equalsIgnoreCase(c.getNodeName()))
						{
							set = new StatsSet();
							set.set("castleId", castleId);
							
							attrs = c.getAttributes();
							for (int i = 0; i < attrs.getLength(); i++)
							{
								att = attrs.item(i);
								set.set(att.getNodeName(), att.getNodeValue());
							}
							_seeds.put(set.getInt("seedId"), new L2Seed(set));
						}
					}
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:37,代码来源:CastleManorManager.java

示例14: prettyPrintDOMWithEncoding

import org.w3c.dom.Document; //导入方法依赖的package包/类
public static void prettyPrintDOMWithEncoding(Document doc, String defaultEncoding, Result result) {
	Node firstChild = doc.getFirstChild();
	boolean omitXMLDeclaration = false;
	String encoding = defaultEncoding; // default Encoding char set if non
										// is found in the PI

	if ((firstChild.getNodeType() == Document.PROCESSING_INSTRUCTION_NODE)
			&& (firstChild.getNodeName().equals("xml"))) {
		omitXMLDeclaration = true;
		String piValue = firstChild.getNodeValue();
		// extract from PI the encoding Char Set
		int encodingOffset = piValue.indexOf("encoding=\"");
		if (encodingOffset != -1) {
			encoding = piValue.substring(encodingOffset + 10);
			// remove the last "
			encoding = encoding.substring(0, encoding.length() - 1);
		}
	}

	try {
		Transformer t = getNewTransformer();
		t.setOutputProperty(OutputKeys.ENCODING, encoding);
		t.setOutputProperty(OutputKeys.INDENT, "yes");
		t.setOutputProperty(OutputKeys.METHOD, "xml"); // xml, html, text
		t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
		t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ? "yes" : "no");
		t.transform(new DOMSource(doc), result);
	} catch (Exception e) {
		Engine.logEngine.error("Unexpected exception while pretty print DOM", e);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:32,代码来源:XMLUtils.java

示例15: parseDocument

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Override
public void parseDocument(Document doc, File f)
{
	for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
	{
		if ("list".equalsIgnoreCase(n.getNodeName()))
		{
			for (Node b = n.getFirstChild(); b != null; b = b.getNextSibling())
			{
				if ("spawn".equalsIgnoreCase(b.getNodeName()))
				{
					final NamedNodeMap attrs = b.getAttributes();
					final int[] info =
					{
						parseInteger(attrs, "sepulcherId"),
						parseInteger(attrs, "wave"),
						parseInteger(attrs, "npcId"),
						parseInteger(attrs, "x"),
						parseInteger(attrs, "y"),
						parseInteger(attrs, "z"),
						parseInteger(attrs, "heading")
					};
					ROOM_SPAWN_DATA.add(info);
				}
			}
		}
	}
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:29,代码来源:FourSepulchers.java


注:本文中的org.w3c.dom.Document.getFirstChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。