Example #1
0
  private MbElement getAttributeElement(String ns, String name) throws MbException {
    MbXPath xpath = new MbXPath("@" + name, getMbElement());

    if (ns != null) {
      xpath.setDefaultNamespace(ns);
    }

    List matches = (List) getMbElement().evaluateXPath(xpath);

    if (matches.size() > 0) {
      return ((MbElement) matches.get(0));
    } else {
      return null;
    }
  }
Example #2
0
  public String[] getAttributeNames(String ns) throws MbException {
    MbXPath xpath = new MbXPath("@*", getMbElement());

    if (ns != null) {
      xpath.setDefaultNamespace(ns);
    }

    List matches = (List) getMbElement().evaluateXPath(xpath);

    String[] names = new String[matches.size()];

    for (int i = 0; i < names.length; i++) {
      names[i] = ((MbElement) matches.get(i)).getName();
    }

    return names;
  }