List of usage examples for org.jdom2 Element getChildTextTrim
public String getChildTextTrim(final String cname, final Namespace ns)
From source file:net.instantcom.mm7.MM7Request.java
License:Open Source License
@Override public void load(Element element) { super.load(element); Element body = element.getChild("Body", MM7Message.ENVELOPE); Element req = (Element) body.getChildren().get(0); setVasId(req.getChildTextTrim("VASID", req.getNamespace())); setVaspId(req.getChildTextTrim("VASPID", req.getNamespace())); setRelayServerId(req.getChildTextTrim("MMSRelayServerID", req.getNamespace())); }
From source file:net.instantcom.mm7.MM7Response.java
License:Open Source License
@Override public void load(Element element) { super.load(element); Element body = element.getChild("Body", MM7Message.ENVELOPE); Element child = (Element) body.getChildren().get(0); // Handle SOAP faults, status will be found in a Fault detail element if ("Fault".equals(child.getName())) { //child = (Element) child.getChild("detail").getChildren().get(0); if (element.getNamespace("") != null) { child = (Element) child.getChild("detail", element.getNamespace("")).getChildren().get(0); } else {/*from w w w.j a v a2s.com*/ child = (Element) child.getChild("detail").getChildren().get(0); } } Element status = child.getChild("Status", namespace); if (status != null) { setStatusCode(Integer.parseInt(status.getChildTextTrim("StatusCode", namespace))); setStatusText(status.getChildTextTrim("StatusText", namespace)); } }
From source file:net.instantcom.mm7.SubmitRsp.java
License:Open Source License
@Override public void load(Element element) { super.load(element); Element body = element.getChild("Body", MM7Message.ENVELOPE); Element rsp = body.getChild("SubmitRsp", namespace); setMessageId(rsp.getChildTextTrim("MessageID", namespace)); }
From source file:org.shaman.rpg.battle.attack.MonsterAttackLoader.java
private List<MonsterAttack> loadFromXml(Document doc) { //the document is valid, so start with analysing it Collection<Element> attacks = doc.getRootElement().getChildren("Attack", namespace); List<MonsterAttack> list = new ArrayList<MonsterAttack>(attacks.size()); //load races/* www .j a v a 2s. c o m*/ for (Element e : attacks) { MonsterAttack attack = new MonsterAttack(); //load name attack.setName(e.getChildTextTrim("name", namespace)); //load attack class AttackClass ac = new AttackClass(Integer.parseInt(e.getChildTextTrim("element", namespace)), AttackClass.Category.valueOf(e.getChildTextTrim("category", namespace)), AttackClass.School.valueOf(e.getChildTextTrim("school", namespace)), AttackClass.CalculationType.valueOf(e.getChildTextTrim("calculation", namespace)), AttackClass.Target.valueOf(e.getChildTextTrim("target", namespace))); attack.setAttackClass(ac); //load strength attack.setBaseStrength(Integer.parseInt(e.getChildTextTrim("strength", namespace))); //load precision attack.setPrecision(Integer.parseInt(e.getChildTextTrim("precision", namespace)) / 100f); //load attack points attack.setActionPoints(Integer.parseInt(e.getChildTextTrim("attackPoints", namespace))); //TODO: custom attributes //add to list list.add(attack); } return list; }
From source file:org.shaman.rpg.battle.monster.MonsterRaceLoader.java
private List<MonsterRace> loadFromXml(Document doc) { //the document is valid, so start with analysing it Collection<Element> races = doc.getRootElement().getChildren("MonsterRace", namespace); List<MonsterRace> list = new ArrayList<MonsterRace>(races.size()); //load races/* w w w . j a v a2 s.c om*/ for (Element e : races) { MonsterRace race = new MonsterRace(); //load name race.setName(e.getChildTextTrim("name", namespace)); //load element race.setElementID(Integer.valueOf(e.getChildTextTrim("element", namespace))); //load state values for (StateValue v : StateValue.values()) { if (v == StateValue.ATTACK_POINTS) { continue; //ignore attack points } race.setStateValue(v, Integer.parseInt(e.getChildTextTrim(v.toString(), namespace))); } //TODO: custom attributes //add to list list.add(race); } return list; }
From source file:XMLReader.ReadUsersXML.java
License:Open Source License
public static User findUserByFullName(User usuario, String xmlSource) { try {/* w ww . j a v a 2s . c o m*/ Element rootNode = builder.build(xmlSource).getRootElement(); List<Element> lista = rootNode.getChildren("user", ns); for (Element e : lista) if (e.getChildTextTrim("nombres", ns).equals(usuario.getNombres()) && e.getChildTextTrim("apPat", ns).equals(usuario.getApPaterno()) && e.getChildTextTrim("apMat", ns).equals(usuario.getApMaterno())) return new User(e, ns); } catch (IOException io) { System.out.println(io.getMessage()); } catch (JDOMException jdomex) { System.out.println(jdomex.getMessage()); } return null; }
From source file:XMLWriter.WriteCommentsXML.java
License:Open Source License
public static boolean removeComments(String idUser, List<String> idComments, String xmlSource) { try {//from www. j a v a2 s . co m Document doc = builder.build(xmlSource); Element rootNode = doc.getRootElement(); List<Element> lista = rootNode.getChildren("comentario", ns); boolean error = false; for (Element e : lista) if (e.getChildTextTrim("idUsuario", ns).equals(idUser) && idComments.contains(e.getAttributeValue("id"))) error = (error || !rootNode.removeContent(e)); if (error) return false; Format form = Format.getPrettyFormat().clone(); form.setTextMode(Format.TextMode.TRIM_FULL_WHITE); XMLOutputter xmlOut = new XMLOutputter(form); FileOutputStream file = new FileOutputStream(xmlSource); xmlOut.output(doc, file); file.close(); } catch (IOException io) { System.out.println(io.getMessage()); } catch (JDOMException jdomex) { System.out.println(jdomex.getMessage()); } return true; }