public HttpNode child(String n) {
   for (int i = 0; i < childs.size(); i++) {
     HttpNode x = (HttpNode) childs.elementAt(i);
     if (x.getName().equals(n)) return x;
   }
   return new HttpNode();
 }
 public String childValue(String n) {
   for (int i = 0; i < childs.size(); i++) {
     HttpNode x = (HttpNode) childs.elementAt(i);
     if (x.getName().equals(n)) return x.getValue();
   }
   return "";
 }
 public boolean hasValueOfChild(String n) {
   for (int i = 0; i < childs.size(); i++) {
     HttpNode x = (HttpNode) childs.elementAt(i);
     if (x.getValue().equals(n)) return true;
   }
   return false;
 }
 public boolean hasChild(String n) {
   for (int i = 0; i < childs.size(); i++) {
     HttpNode x = (HttpNode) childs.elementAt(i);
     if (x.getName().equals(n)) // PATCH 2008 thanks..
     return true;
   }
   return false;
 }
  public void parse(String stBuff, InputStream s) throws Exception {
    pos = 0;
    is = s;
    buff = stBuff;
    try {
      char ch = nextChar();
      if (ch != '<') return;
      if (nextChar() == '?') {
        // Read header
        while (nextChar() != '>') {}

        while (nextChar() != '>') {}

        nextChar();
      } else pos--;
      String n = "";
      n += nextChar();
      while ((ch = nextChar()) != '>') {
        n += ch;
      }
      //                      System.out.println("name = "+n);
      boolean hasEnd = false;
      if (n.charAt(n.length() - 1) == '/') {
        hasEnd = true;
        n = n.substring(0, n.length() - 1);
      }
      if (n.indexOf(' ') != -1) {
        String attrs = n.substring(n.indexOf(' '), n.length()).trim() + ' ';
        n = n.substring(0, n.indexOf(' '));
        for (; attrs.length() > 1; ) {
          String aName = attrs.substring(0, attrs.indexOf('='));
          attrs = attrs.substring(attrs.indexOf('=') + 1, attrs.length());
          char b = attrs.charAt(0);
          String aValue = attrs.substring(1, attrs.indexOf(b, 1));
          attrs = attrs.substring(attrs.indexOf(b, 1) + 2, attrs.length());
          if (ignoreNS && aName.indexOf(":") > 0) {
            aName = aName.substring(aName.indexOf(":") + 1);
          }
          attributes.put(aName, aValue);
        }
      }
      name = n;
      if (ignoreNS && n.indexOf(":") > 0) {
        name = n.substring(n.indexOf(":") + 1);
      }
      if (!hasEnd) {
        ch = nextChar();
        if (ch == '<') {
          pos--;
          while ((ch = nextChar()) == '<') {
            if (nextChar() == '/') {
              while ((ch = nextChar()) != '>') {}

              break;
            }
            pos--;
            HttpNode x = new HttpNode();
            x.parse("<" + nextChar(), s);
            childs.addElement(x);
          }
        } else {
          value = "" + ch;
          while ((ch = nextChar()) != '<') value += ch;
          while ((ch = nextChar()) != '>') {}
        }
      }

    } catch (Exception e) {

      throw new Exception("Could not read: " + e);
    }
  }