Get Text Content from Xml Node : Xml « Development « Android

Home
Android
1.2D Graphics
2.Animation
3.Core Class
4.Database
5.Date Type
6.Development
7.File
8.Game
9.Hardware
10.Media
11.Network
12.Security
13.UI
14.User Event
Android » Development » Xml 
Get Text Content from Xml Node
     
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 
 * $Id: Dom.java 123 2010-07-20 12:01:48Z chris@rosaloves.com $
 
 @author clewis Jul 18, 2010
 
 */
class Dom {
  public static String getTextContent(Node n) {
    StringBuffer sb = new StringBuffer();
    NodeList nl = n.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
      Node child = nl.item(i);
      if (child.getNodeType() == Node.TEXT_NODE)
        sb.append(child.getNodeValue());
    }
    return sb.toString();
  }

}

   
    
    
    
    
  
Related examples in the same category
1.Using xml resource
2.XML Resource Demo
3.Load style from styles.xml
4.Define PreferenceScreen in xml file
5.Using XML Parser
6.XML-defined adapters can be used to easily create adapters in your own application or to pass adapters to other processes.
7.Xml Parse
8.Xml Serializer Uri
9.Escape un escape Xml
10.Get Xml node value with substring
11.Get value from Element
12.Get attribute value
13.Get field from NamedNodeMap
14.get Node Value With Attribute
15.get Character Data From Element
16.update Xml
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.