File: XMLParseUtil.C

package info (click to toggle)
lttoolbox 1.0.3-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,816 kB
  • ctags: 594
  • sloc: sh: 8,860; cpp: 6,174; makefile: 100
file content (34 lines) | stat: -rw-r--r-- 701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <lttoolbox/XMLParseUtil.H>

string
XMLParseUtil::attrib(xmlTextReaderPtr reader, string const &name)
{
  xmlChar *attrname = xmlCharStrdup(name.c_str());
  xmlChar *myattr = xmlTextReaderGetAttribute(reader, attrname);
  string result = latin1(myattr);
  xmlFree(myattr);
  xmlFree(attrname);
  return result;
}

string
XMLParseUtil::latin1(xmlChar const *input)
{
 if(input == NULL)
  {
    return "";
  }

  int outputlen = xmlStrlen(input) + 1;
  int inputlen = xmlStrlen(input);

  unsigned char output[outputlen];
  
  if(UTF8Toisolat1(output, &outputlen, input, &inputlen) != 0)
  {
  }

  output[outputlen] = 0;
  string result = reinterpret_cast<char *>(output);
  return result;  
}