1
XML을 제공하는 웹 서비스를 사용하여 인터넷 시간을 가져 오려고합니다. 이제 pugixml을 사용하여 xml 파일을 구문 분석하려고합니다. XML이 반환되었습니다pugixml을 사용하여 XML 구문 분석
<?xml version="1.0" encoding="ISO-8859-1" ?>
<timezone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.earthtools.org/timezone.xsd">
<version>1.0</version>
<location>
<latitude>22.5667</latitude>
<longitude>88.3667</longitude>
</location>
<offset>5.5</offset>
<suffix>E*</suffix>
<localtime>20 Jul 2014 14:48:10</localtime>
<isotime>2014-07-20 14:48:10 +0530</isotime>
<utctime>2014-07-20 09:18:10</utctime>
<dst>Unknown</dst>
</timezone>
나는 그것을 분석하려고합니다.
pugi::xml_document doc;
if (!doc.load_file("time.xml")) return -1;
pugi::xml_node tools = doc.child("timezone").child("localtime");
//[code_traverse_iter
for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it)
{
std::cout << "Tool:";
for (pugi::xml_attribute_iterator ait = it->attributes_begin(); ait != it->attributes_end(); ++ait)
{
std::cout << " " << ait->name() << "=" << ait->value();
}
std::cout << std::endl;
}
return 0;
나는
<localtime>20 Jul 2014 14:48:10</localtime>
날이 통해 얻을 수 있도록하십시오이 노드의 값을 가져올 필요가있다.
피씨 : 사용중인 웹 서비스는 http://www.earthtools.org/webservices.htm이며, 누군가를 돕기를 바랍니다.
xml이 그렇게 길지는 않지만 간단한 파서 작업을 수행 할 수 있지만 파서를 사용하고 싶습니다.
고마워 ... –