Пример #1
0
bool gpl::xml::openXPath(const char* fileName, int blank /*= 1*/)
{
	if (m_xml->doc != NULL)
		closeXPath();
	xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
	xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
	xmlSubstituteEntitiesDefaultValue = 1;
	xmlKeepBlanksDefault(blank);
	if (xmlAddEncodingAlias("ISO-8859-1", "GBK") < 0 ||
		xmlAddEncodingAlias("ISO-8859-1", "GB2312") < 0)
		return false;
	m_xml->doc = xmlParseFile(fileName);
	if (m_xml->doc == NULL)
		return false;

	m_xml->context = xmlXPathNewContext(m_xml->doc);
	m_xml->context->node = xmlDocGetRootElement(m_xml->doc);
	if (m_xml->context->node == NULL)
	{
		xmlFreeDoc(m_xml->doc);
		return false;
	}
	m_xml->resource = NULL;
	m_fileName = fileName;
	m_xml->isOnlyEntityName = false;

	return true;
}
Пример #2
0
void charset_init()
{
    int i;

    for (i = 0; chars_aliases[i].real != NULL; i++) {
      xmlAddEncodingAlias(chars_aliases[i].real,chars_aliases[i].alias);
      /*debug("encoding",0,"Add encoding for %s",chars_aliases[i].alias);*/
    }
}
Пример #3
0
bool gpl::xml::openBufferXPath(const char* buffer, int size /*= -1*/, int blank /*= 1*/)
{
	int len = strlen(buffer);
	if (size == 0 || len < size)
		return false;
	if (size == -1)
	{
		size = len;
	}
	///////////////////////////////////////////////////////  
	if (m_xml->doc != NULL)
		closeXPath();
	xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
	xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
	xmlSubstituteEntitiesDefaultValue = 1;
	if (xmlAddEncodingAlias("ISO-8859-2", "GBK") < 0 ||
		xmlAddEncodingAlias("ISO-8859-2", "GB2312") < 0)
		return false;
	xmlKeepBlanksDefault(blank);
	m_xml->doc = xmlParseMemory(buffer, size);
	if (m_xml->doc == NULL)
		return false;

	m_xml->context = xmlXPathNewContext(m_xml->doc);
	m_xml->context->node = xmlDocGetRootElement(m_xml->doc);
	if (m_xml->context->node == NULL)
	{
		xmlFreeDoc(m_xml->doc);
		return false;
	}
	m_xml->resource = NULL;
	m_fileName = "";
	m_xml->isOnlyEntityName = false;

	///////////////////////////////////////////////////////  
	return true;
}