Java Code Examples for org.w3c.dom.CharacterData#getData()

The following examples show how to use org.w3c.dom.CharacterData#getData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueuePoller.java    From swift-k with Apache License 2.0 6 votes vote down vote up
/**
 * getDataFromElement - Make XML parsing a bit easier 
 * @param e XML Element
 * @return XML data as a String
 */
public static String getDataFromElement(Element e) {
	try {
		Node child = e.getFirstChild();
		if (child instanceof CharacterData) {
			CharacterData cd = (CharacterData) child;
			return cd.getData();
		}
	}
	
	catch (Exception ex) {
		logger.debug("Error in getDataFromElement");
		logger.debug(ex.getMessage());
		logger.debug(ex.getStackTrace());
	}
	return "";
}
 
Example 2
Source File: TemplateRegistration.java    From azure-notificationhubs-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void loadCustomXmlData(Element payloadNode) {
	NodeList bodyTemplateElements = payloadNode.getElementsByTagName("BodyTemplate");
	if (bodyTemplateElements.getLength() > 0) {
		NodeList bodyNodes = bodyTemplateElements.item(0).getChildNodes();
		for (int i = 0; i < bodyNodes.getLength(); i++) {
			if (bodyNodes.item(i) instanceof CharacterData) {
				CharacterData data = (CharacterData) bodyNodes.item(i);
				mBodyTemplate = data.getData();
				break;
			}
		}
	}

	setName(getNodeValue(payloadNode, "TemplateName"));
}
 
Example 3
Source File: FrontierSiliconRadioApiResult.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * convert the value of a given XML element to a string for further processing
 * 
 * @param e
 *            XML Element
 * @return the elements value converted to string
 */
private static String getCharacterDataFromElement(Element e) {
    final Node child = e.getFirstChild();
    if (child instanceof CharacterData) {
        final CharacterData cd = (CharacterData) child;
        return cd.getData();
    }
    return "";
}
 
Example 4
Source File: HttpGetAndroidWrapper.java    From gsn with GNU General Public License v3.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) 
{
	    Node child = e.getFirstChild();
	    if (child instanceof CharacterData) {
	       CharacterData cd = (CharacterData) child;
	       return cd.getData();
	    }
	    return "?";
 }
 
Example 5
Source File: parseKML.java    From mil-sym-android with Apache License 2.0 5 votes vote down vote up
/**
     * @param kmlRecords
     * @param coordStrings new ArrayList passed by the caller to hold the
     * coordinates
     * @throws Exception
     */
//    protected static void parse(String kmlRecords, ArrayList<String> coordStrings) throws Exception {
//
//        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
//        InputSource is = new InputSource();
//        is.setCharacterStream(new StringReader(kmlRecords));
//        Document doc = db.parse(is);
//        NodeList nodes = doc.getElementsByTagName("LineString");
//        for (int i = 0; i < nodes.getLength(); i++) {
//            Element element = (Element) nodes.item(i);
//
//            NodeList alt = element.getElementsByTagName("altitudeMode");
//            Element line = (Element) alt.item(0);
//            System.out.println("altitude mode: " + getCharacterDataFromElement(line));
//
//            NodeList coords = element.getElementsByTagName("coordinates");
//            line = (Element) coords.item(0);
//            System.out.println("coordinates: " + getCharacterDataFromElement(line));
//            coordStrings.add(getCharacterDataFromElement(line));
//        }
//        return;
//    }

    private static String getCharacterDataFromElement(Element e) {
        Node child = e.getFirstChild();
        if (child instanceof CharacterData) {
            CharacterData cd = (CharacterData) child;
            return cd.getData();
        }
        return "";
    }
 
Example 6
Source File: parseKML.java    From mil-sym-android with Apache License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) {
    Node child = e.getFirstChild();
    if (child instanceof CharacterData) {
        CharacterData cd = (CharacterData) child;
        return cd.getData();
    }
    return "";
}
 
Example 7
Source File: FrontierSiliconRadioApiResult.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * convert the value of a given XML element to a string for further processing
 *
 * @param e
 *            XML Element
 * @return the elements value converted to string
 */
private static String getCharacterDataFromElement(Element e) {
    final Node child = e.getFirstChild();
    if (child instanceof CharacterData) {
        final CharacterData cd = (CharacterData) child;
        return cd.getData();
    }
    return "";
}
 
Example 8
Source File: WemoLinkDiscoveryService.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) {
    Node child = e.getFirstChild();
    if (child instanceof CharacterData) {
        CharacterData cd = (CharacterData) child;
        return cd.getData();
    }
    return "?";
}
 
Example 9
Source File: WemoMakerHandler.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) {
    Node child = e.getFirstChild();
    if (child instanceof CharacterData) {
        CharacterData cd = (CharacterData) child;
        return cd.getData();
    }
    return "?";
}
 
Example 10
Source File: WemoCoffeeHandler.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) {
    Node child = e.getFirstChild();
    if (child instanceof CharacterData) {
        CharacterData cd = (CharacterData) child;
        return cd.getData();
    }
    return "?";
}
 
Example 11
Source File: TopologyReaderXML.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) {
	org.w3c.dom.Node child = e.getFirstChild();
	if (child instanceof CharacterData) {
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	} else {
		return "?";
	}
}
 
Example 12
Source File: TopologyModuleParamsArray.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
/**
 * This method gets the value from an XML element.
 * @param e XML Element.
 * @return Value as string.
 */
private String getCharacterDataFromElement(Element e) {
	if (e == null)
	{
		return null;
	}
	Node child = e.getFirstChild();
	if (child instanceof CharacterData) {
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	} else {
		return "?";
	}
}
 
Example 13
Source File: UtilsFunctions.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e)
{
	Node child = e.getFirstChild();
	if (child instanceof CharacterData) 
	{
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	} 
	else 
	{
		return "?";
	}
}
 
Example 14
Source File: Topology.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) {
	org.w3c.dom.Node child = e.getFirstChild();
	if (child instanceof CharacterData) {
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	} else {
		return "?";
	}
}
 
Example 15
Source File: TEDUpdaterFloodlight.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
private String getCharacterDataFromElement(Element e) {
	Node child = e.getFirstChild();
	if (child instanceof CharacterData) {
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	} else {
		return "?";
	}
}
 
Example 16
Source File: TEDUpdaterController.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
private static String getCharacterDataFromElement(Element e) 
{
	Node child = e.getFirstChild();
	if (child instanceof CharacterData) 
	{
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	}
	else 
	{
		return "?";
	}
}
 
Example 17
Source File: TEDUpdaterODL.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
private String getCharacterDataFromElement(Element e) {
	Node child = e.getFirstChild();
	if (child instanceof CharacterData) {
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	} else {
		return "?";
	}
}
 
Example 18
Source File: FileTEDBUpdater.java    From netphony-topology with Apache License 2.0 5 votes vote down vote up
public static String getCharacterDataFromElement(Element e) {
	Node child = e.getFirstChild();
	if (child instanceof CharacterData) {
		CharacterData cd = (CharacterData) child;
		return cd.getData();
	} else {
		return "?";
	}
}
 
Example 19
Source File: ElementImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected TextImpl convertToSoapText(CharacterData characterData) {
        final Node soapNode = getSoapDocument().findIfPresent(characterData);
        if (soapNode instanceof TextImpl) {
            return (TextImpl) soapNode;
        } else {
            TextImpl t = null;
            switch (characterData.getNodeType()) {
                case CDATA_SECTION_NODE:
                    t = new CDATAImpl(getSoapDocument(), characterData.getData());
                    break;
                case COMMENT_NODE:
                    t = new SOAPCommentImpl(getSoapDocument(), characterData.getData());
                    break;
                case TEXT_NODE:
                    t = new SOAPTextImpl(getSoapDocument(), characterData.getData());
                    break;
            }
            Node parent = getSoapDocument().find(characterData.getParentNode());
            if (parent != null) {
                parent.replaceChild(t, characterData);
            } // XXX else throw an exception?

            return t;

//            return replaceElementWithSOAPElement(
//                element,
//                (ElementImpl) createElement(NameImpl.copyElementName(element)));
        }
    }
 
Example 20
Source File: Xml.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
public static String contents(CharacterData characterData) {
    return characterData.getData();
}