Code example for Element

Methods: getAttributegetAttributeNSgetElementsByTagName

0
					NodeList rewards=modeEl.getElementsByTagName("reward");
					if(rewards!=null && rewards.getLength()>0){
						Element rewardEl=(Element) rewards.item(0);
						Reward reward=null;
						 
						String xsitype=rewardEl.getAttributeNS(NAMESPACE_XSI, "type");
						if(xsitype!=null && xsitype.equals("intentReward")){
							reward=new IntentReward();
							NodeList actionEls=rewardEl.getElementsByTagName("action");
							if(actionEls!=null && actionEls.getLength()>0){
								Element actionEl=(Element) actionEls.item(0);
								((IntentReward)reward).setAction(actionEl.getTextContent());
							} 
							else 
								logger.warn("Could not load intentReward: action not found");
							 
							NodeList uriEls=rewardEl.getElementsByTagName("uri");
							if(uriEls!=null && uriEls.getLength()>0){
								Element uriEl=(Element) uriEls.item(0);
								((IntentReward)reward).setUri(uriEl.getTextContent());
							} 
							else 
								logger.warn("Could not load intentReward: action not found");
						} 
						 
						if(reward!=null){
							//pointsRequired 
							int pointsRequired=Integer.parseInt(rewardEl.getAttribute("pointsRequired"));
							reward.setPointsRequired(pointsRequired);
							pointsMode.setReward(reward);
							 
							//text 
							NodeList textEls=rewardEl.getElementsByTagName("text");
							if(textEls!=null && textEls.getLength()>0){
								Element textEl=(Element) textEls.item(0);
								reward.setText(textEl.getTextContent());
							} 
						} 
Contextual code suggestions in your IDE  Get Codota for Java