Search in sources :

Example 6 with XMLReader

use of com.genexus.xml.XMLReader in project JavaClasses by genexuslabs.

the class GXBaseCollection method fromxml.

@Override
public boolean fromxml(String xml, GXBaseCollection<SdtMessages_Message> messages, String collName) {
    try {
        XMLReader reader = new XMLReader();
        reader.openFromString(xml);
        short result;
        result = readCollectionFromXML(reader);
        reader.close();
        if (result <= 0) {
            CommonUtil.ErrorToMessages(String.valueOf(reader.getErrCode()), reader.getErrDescription(), messages);
            return false;
        } else
            return true;
    } catch (Exception ex) {
        CommonUtil.ErrorToMessages("fromxml error", ex.getMessage(), messages);
        return false;
    }
}
Also used : XMLReader(com.genexus.xml.XMLReader) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with XMLReader

use of com.genexus.xml.XMLReader in project JavaClasses by genexuslabs.

the class GXSimpleCollection method fromxml.

public boolean fromxml(String xml, GXBaseCollection<SdtMessages_Message> messages, String collName) {
    try {
        if (SpecificImplementation.Application.getProperty("SIMPLE_XML_SUPPORT", "0").equals("1")) {
            xml = xml.replaceAll("<item>", "<item class=\"" + elementsType.getName() + "\">");
            GXXMLSerializer.deserializeSimpleXml(this, xml);
            return true;
        } else {
            XMLReader reader = new XMLReader();
            reader.openFromString(xml);
            short result;
            result = readIntegralCollectionFromXML(reader, "item");
            reader.close();
            if (result <= 0) {
                CommonUtil.ErrorToMessages(String.valueOf(reader.getErrCode()), reader.getErrDescription(), messages);
                return false;
            } else
                return true;
        }
    } catch (Exception ex) {
        CommonUtil.ErrorToMessages("fromxml error", ex.getMessage(), messages);
        return false;
    }
}
Also used : XMLReader(com.genexus.xml.XMLReader) JSONException(json.org.json.JSONException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

XMLReader (com.genexus.xml.XMLReader)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Vector (java.util.Vector)2 AbstractGXFile (com.genexus.common.classes.AbstractGXFile)1 GXDirectory (com.genexus.util.GXDirectory)1 GXFileCollection (com.genexus.util.GXFileCollection)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 JSONException (json.org.json.JSONException)1