List of usage examples for org.jdom2 Document getRootElement
public Element getRootElement()
Element
for this Document
From source file:com.sun.syndication.io.impl.RSS090Parser.java
License:Open Source License
public boolean isMyType(Document document) { boolean ok = false; Element rssRoot = document.getRootElement(); Namespace defaultNS = rssRoot.getNamespace(); List additionalNSs = rssRoot.getAdditionalNamespaces(); ok = defaultNS != null && defaultNS.equals(getRDFNamespace()); if (ok) {/* w ww .ja v a 2 s.co m*/ if (additionalNSs == null) { ok = false; } else { ok = false; for (int i = 0; !ok && i < additionalNSs.size(); i++) { ok = getRSSNamespace().equals(additionalNSs.get(i)); } } } return ok; }
From source file:com.sun.syndication.io.impl.RSS090Parser.java
License:Open Source License
public WireFeed parse(Document document, boolean validate) throws IllegalArgumentException, FeedException { if (validate) { validateFeed(document);/* w w w. jav a2 s. c o m*/ } Element rssRoot = document.getRootElement(); return parseChannel(rssRoot); }
From source file:com.sun.syndication.io.impl.RSS091NetscapeParser.java
License:Open Source License
public boolean isMyType(Document document) { boolean ok = false; Element rssRoot = document.getRootElement(); ok = rssRoot.getName().equals("rss"); if (ok) {/*from w ww .j av a 2 s . c o m*/ ok = false; Attribute version = rssRoot.getAttribute("version"); if (version != null) { ok = version.getValue().equals(getRSSVersion()); if (ok) { ok = false; DocType docType = document.getDocType(); if (docType != null) { ok = ELEMENT_NAME.equals(docType.getElementName()); ok = ok && PUBLIC_ID.equals(docType.getPublicID()); ok = ok && SYSTEM_ID.equals(docType.getSystemID()); } } } } return ok; }
From source file:com.sun.syndication.io.impl.RSS091UserlandParser.java
License:Open Source License
public boolean isMyType(Document document) { boolean ok;//from w w w . j a va 2 s . c o m Element rssRoot = document.getRootElement(); ok = rssRoot.getName().equals("rss"); if (ok) { ok = false; Attribute version = rssRoot.getAttribute("version"); if (version != null) { ok = version.getValue().equals(getRSSVersion()); } } return ok; }
From source file:com.sun.syndication.io.impl.RSS10Parser.java
License:Open Source License
/** * Indicates if a JDom document is an RSS instance that can be parsed with the parser. * <p/>/*from w w w. ja v a2 s .c o m*/ * It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and * RSS ("http://purl.org/rss/1.0/") namespaces being defined in the root element. * * @param document document to check if it can be parsed with this parser implementation. * @return <b>true</b> if the document is RSS1., <b>false</b> otherwise. */ public boolean isMyType(Document document) { boolean ok = false; Element rssRoot = document.getRootElement(); Namespace defaultNS = rssRoot.getNamespace(); List additionalNSs = rssRoot.getAdditionalNamespaces(); ok = defaultNS != null && defaultNS.equals(getRDFNamespace()); if (ok) { if (additionalNSs == null) { ok = false; } else { ok = false; for (int i = 0; !ok && i < additionalNSs.size(); i++) { ok = getRSSNamespace().equals(additionalNSs.get(i)); } } } return ok; }
From source file:com.sun.syndication.io.impl.RSS20Parser.java
License:Open Source License
public boolean isMyType(Document document) { boolean ok;/*from w ww . j a v a 2 s. c om*/ Element rssRoot = document.getRootElement(); ok = rssRoot.getName().equals("rss"); if (ok) { ok = false; Attribute version = rssRoot.getAttribute("version"); if (version != null) { // At this point, as far ROME is concerned RSS 2.0, 2.00 and // 2.0.X are all the same, so let's use startsWith for leniency. ok = version.getValue().startsWith(getRSSVersion()); } } return ok; }
From source file:com.sun.syndication.io.impl.RSS20wNSParser.java
License:Open Source License
public boolean isMyType(Document document) { Element rssRoot = document.getRootElement(); Namespace defaultNS = rssRoot.getNamespace(); boolean ok = defaultNS != null && defaultNS.equals(getRSSNamespace()); if (ok) {/*from w w w .jav a 2 s .c om*/ ok = super.isMyType(document); } return ok; }
From source file:com.swordlord.gozer.builder.Parser.java
License:Open Source License
/** * Create the tree/*from w w w . j ava2s . c o m*/ * * @param document */ public void createTree(Document document) { Element root = document.getRootElement(); parseElement(root, null); }
From source file:com.tactfactory.harmony.dependencies.android.sdk.AndroidSDKManager.java
License:Open Source License
/** * Find the latest SDK Tools link./*from w ww . j a v a2s . co m*/ * * @param platform The user platform * @return The latest SDK tools link */ public final String findLatestSDKToolsLink(final String platform) { String result = null; Document document = XMLUtils.getRemoteXML(SDK_URL + XML_REPO_FILE); Element root = document.getRootElement(); Namespace ns = root.getNamespace("sdk"); Element sdkTool = root.getChild("tool", ns); List<Element> sdkArchives = sdkTool.getChild("archives", ns).getChildren(); for (Element sdkArchive : sdkArchives) { if (sdkArchive.getAttribute("os").getValue().equals(platform)) { result = SDK_URL + sdkArchive.getChildText("url", ns); } } return result; }
From source file:com.tactfactory.harmony.platform.android.updater.HomeActivityUpdaterAndroid.java
License:Open Source License
/** * Add a button to main.xml./*w w w .ja v a 2 s.co m*/ * @param text The displayed text * @param buttonId The button id */ private void addButtonToMainXML(final String text, final String buttonId) { String xmlFileName = this.adapter.getRessourceLayoutPath() + "main.xml"; Document doc = XMLUtils.openXML(xmlFileName); Namespace androidNs = doc.getRootElement().getNamespace("android"); Element linearL = doc.getRootElement().getChild("LinearLayout"); boolean alreadyExists = false; for (Element element : linearL.getChildren("Button")) { if (element.getAttributeValue("id", androidNs).equals("@+id/" + buttonId)) { alreadyExists = true; } } if (!alreadyExists) { Element newButton = new Element("Button"); newButton.setAttribute("id", "@+id/" + buttonId, androidNs); newButton.setAttribute("layout_width", "match_parent", androidNs); newButton.setAttribute("layout_height", "wrap_content", androidNs); newButton.setAttribute("text", text, androidNs); linearL.addContent(newButton); } XMLUtils.writeXMLToFile(doc, xmlFileName); }