Package fi.luomus.commons.xml

Examples of fi.luomus.commons.xml.XMLReader


        } catch (URISyntaxException e) {
            throw new RuntimeException("Malformed URI", e);
        }

        try {
            String rootNodeName = new XMLReader().parse(document).getRootNode().getName();
            if (!rootNodeName.equals("SimpleDarwinRecordSet")) {
                return null;
            }
            return document;
        } catch (IllegalArgumentException ex) {
View Full Code Here


          
        }

        @Override
        public Document contentAsDocument(HttpUriRequest request) throws IOException {
            return new XMLReader().parse(getResponseForRequest(request));
        }
View Full Code Here

   * <auth_for>Peto</auth_for>
   * </login>
   */
  private Map<String, String> parseUserModel(String xml) throws Exception {
    Map<String, String> usermodel = new HashMap<String, String>();
    XMLReader reader = new XMLReader();
    Document document = reader.parse(xml);
    Node rootNode = document.getRootNode();
    String userType = rootNode.getAttribute("type");
    usermodel.put(USER_TYPE, userType);
    for (Node node : rootNode.getChildNodes()) {
      usermodel.put(node.getName(), node.getContents());
View Full Code Here

  @Override
  public void sendForCorrections(String id, String message) throws Exception {
    HttpPost request = new HttpPost(uri + "/post/update/" + systemID);

    String xml = this.getXML(id);
    Document document = new XMLReader().parse(xml);
    Node root = document.getRootNode();
    if (root.hasChildNodes("message")) {
      Node messageNode = root.getNode("message");
      messageNode.setContents(messageNode.getContents() + " \n " + message);
    } else {
View Full Code Here

  }

  public static FormData readFormData(String xml, String systemId) throws MalformedFormDataException {
    Document document = null;
    try {
      document = new XMLReader().parse(xml);
    } catch (Exception e) {
      throw new MalformedFormDataException("Form data was malformed: " + xml);
    }
    Node formData = document.getRootNode();
    String id = null;
View Full Code Here

      String expected = "" +
      "<?xml version='1.0' encoding='utf-8'?>\n" +
      "<root attribute=\"value with &quot;quotes&quot; &amp; &apos;apostrophes&apos;\" second=\"other &lt;value&gt;\" />";
      assertEquals(expected.trim(), xml.trim());
     
      XMLReader reader = new XMLReader();
      document = reader.parse(xml);
      root = document.getRootNode();
      assertEquals("root", root.getName());
      assertEquals("", root.getContents());
      assertEquals(false, root.hasChildNodes());
      assertEquals(false, root.hasContents());
View Full Code Here

      "  </data>\n" +
      "\n" +
      "</root>";
      assertEquals(expected.trim(), xml.trim());
     
      XMLReader reader = new XMLReader();
      document = reader.parse(xml);
      root = document.getRootNode();
      assertEquals(true, root.hasChildNodes());
      assertEquals(false, root.hasContents());
      assertEquals(3, root.getChildNodes().size());
      assertEquals(false, root.hasAttributes());
View Full Code Here

      " newline</node>\n" +
      "\n" +
      "</root>";
      assertEquals(expected.trim(), xml.trim());
     
      XMLReader reader = new XMLReader();
      document = reader.parse(xml);
      Node node = document.getRootNode().getNode("node");
     
      expected = "" +
      "something with a \n" +
      " newline";
View Full Code Here

    }
  }

  private static void xmlReaderExample() {
    String xml = "<root><child>Jee</child></root>";
    Document document = new XMLReader().parse(xml);
    String content = document.getRootNode().getNode("child").getContents();
    assert(content.equals("Jee"));
  }
View Full Code Here

   * @throws IOException
   * @throws ClientProtocolException
   */
  public Document contentAsDocument(HttpUriRequest request) throws IOException, ClientProtocolException {
    String response = contentAsString(request);
    XMLReader reader = new XMLReader();
    Document doc = reader.parse(response);
    return doc;
  }
View Full Code Here

TOP

Related Classes of fi.luomus.commons.xml.XMLReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.