Element textElem = docElem.getFirstChildElement("TEXT"); StringBuilder text = new StringBuilder(); int offset = 0;
protected Request xml2Request(final Document doc) throws MalformedURLException, XMLException { // get the rootNode Element rootNode = doc.getRootElement(); if (!"rest-client".equals(rootNode.getQualifiedName())) { throw new XMLException("Root node is not <rest-client>"); } // checking correct rest version final String rcVersion = rootNode.getAttributeValue("version"); try { Versions.versionValidCheck(rcVersion); } catch(Versions.VersionValidationException ex) { throw new XMLException(ex); } readVersion = rcVersion; // if more than two request element is present then throw the exception if (rootNode.getChildElements().size() != 1) { throw new XMLException("There can be only one child node for root node: <request>"); } // minimum one request element is present in xml if (rootNode.getFirstChildElement("request") == null) { throw new XMLException("The child node of <rest-client> should be <request>"); } Element requestNode = rootNode.getFirstChildElement("request"); return getRequestBean(requestNode); }
if (rootNode.getFirstChildElement("response") == null) { throw new XMLException("The child node of <rest-client> should be <response>"); responseNode = rootNode.getFirstChildElement("response"); for (int i = 0; i < responseNode.getChildElements().size(); i++) { tNode = responseNode.getChildElements().get(i);
public APerson(Element person) { first = person .getFirstChildElement("first").getValue(); last = person .getFirstChildElement("last").getValue(); } @Override
public Element getFirstChildElement(String name) { nu.xom.Element body = xomElement.getFirstChildElement(name); if (body == null) { return null; } return new Element(body); }
private static @Nullable Element getElement( final Element element, final String name) { return element.getFirstChildElement(name, SXML.XML_URI.toString()); }
protected ResultElement getResultElement(nu.xom.Element eResult) throws IOException { nu.xom.Element eObjectives = eResult.getFirstChildElement("objectives"); Collection<ObjectiveElement> objectiveElements = (eObjectives != null) ? getObjectiveElements(eObjectives) : new ArrayList<ObjectiveElement>(); nu.xom.Element eSpecification = eResult.getFirstChildElement("specification"); Specification spec = null; if (eSpecification != null) { SpecificationReader reader = new SpecificationReader(); spec = reader.toSpecification(eSpecification); } return new ResultElement(objectiveElements, spec); }
private void removeIrrelevantStylesheet(Element rootElement) { Element head = rootElement.getFirstChildElement("head"); Element style = head.getFirstChildElement("style"); head.removeChild(style); }
@Override public void beforeParsing(Document document) { Element head = document.getRootElement().getFirstChildElement("head"); removeExistingStyling(head); removeExistingScripts(head); }
@Override public void beforeParsing(Document document) { Element head = document.getRootElement().getFirstChildElement("head"); removeExistingStyling(head); removeExistingScripts(head); }
/** * Adds Content-Type metadata to the document. */ public void beforeParsing(Document document) { Element html = document.getRootElement(); Element head = html.getFirstChildElement("head"); Check.notNull(head, "<head> section is missing from document"); if (!hasContentTypeMetadata(head)) { addContentTypeMetadata(head); } }
/** * Adds Content-Type metadata to the document. */ public void beforeParsing(Document document) { Element html = document.getRootElement(); Element head = html.getFirstChildElement("head"); Check.notNull(head, "<head> section is missing from document"); if (!hasContentTypeMetadata(head)) { addContentTypeMetadata(head); } }
public static void appendModules(Element root, String namespace, List<String> modules) { Element modulesElement = root.getFirstChildElement("modules", namespace); if (modulesElement == null) { modulesElement = new Element("modules", namespace); root.appendChild(modulesElement); } for (String module : modules) { Element moduleElement = new Element("module", namespace); moduleElement.appendChild(module); modulesElement.appendChild(moduleElement); } }
public void beforeParsing(Document document) { Element html = document.getRootElement(); Element head = html.getFirstChildElement("head"); Check.notNull(head, "<head> section is missing from document"); Element script = new Element("script"); script.addAttribute(new Attribute("type", "text/javascript") ); script.appendChild(javaScript); head.insertChild(script, 0); } }
public void beforeParsing(Document document) { nu.xom.Element html = document.getRootElement(); nu.xom.Element head = html.getFirstChildElement("head"); Check.notNull(head, "<head> section is missing from document"); script = new nu.xom.Element("script"); script.addAttribute(new Attribute("type", "text/javascript")); // Fix for Issue #26: Strict XHTML DTD requires an explicit end tag for <script> element // Thanks to Matthias Schwegler for reporting and supplying a fix for this. script.appendChild(""); head.appendChild(script); }
private void removeIrrelevantFooter(Element rootElement) { Element body = rootElement.getFirstChildElement("body"); body.removeChild(rootElement.query("//div[@class='footer']").get(0)); } }
private void removeIrrelevantFooter(Element rootElement) { Element body = rootElement.getFirstChildElement("body"); body.removeChild(rootElement.query("//div[@class='footer']").get(0)); } }
public void beforeParsing(Document document) { Element html = document.getRootElement(); Element head = html.getFirstChildElement("head"); Check.notNull(head, "<head> section is missing from document"); Element script = new Element("script"); script.addAttribute(new Attribute("type", "text/javascript") ); script.appendChild(javaScript); head.insertChild(script, 0); } }
public void beforeParsing(Document document) { nu.xom.Element html = document.getRootElement(); nu.xom.Element head = html.getFirstChildElement("head"); Check.notNull(head, "<head> section is missing from document"); link = new nu.xom.Element("link"); link.addAttribute(new Attribute("type", "text/css")); link.addAttribute(new Attribute("rel", "stylesheet")); head.appendChild(link); }
public void beforeParsing(Document document) { nu.xom.Element html = document.getRootElement(); nu.xom.Element head = html.getFirstChildElement("head"); Check.notNull(head, "<head> section is missing from document"); link = new nu.xom.Element("link"); link.addAttribute(new Attribute("type", "text/css")); link.addAttribute(new Attribute("rel", "stylesheet")); head.appendChild(link); }