rss 뉴스 피드를 읽는 프로그램을 만들었습니다. 자사 웹 사이트 (ABC News, TechCrunch, Engadget)와 같은 일부 웹 사이트에서는 작동하지 않습니다. 이 웹 사이트는 몸 길이가 1 라크 이상입니다. 구문 분석을 위해 XPATH 메서드를 사용합니다. 아마도이 문제는 내가 Bada에 처음 온 것입니다. XML 구문 분석에 사용하는 코드는XML 구문 분석에 실패했습니다.
void
addfeed::OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen)
{
pFrame = Osp::App::Application::GetInstance()->GetAppFrame()->GetFrame();
FormMgr* pFormMgr = dynamic_cast<FormMgr*> (pFrame->GetControl("FormMgr"));
bool flag1=0;
AppLog("####### OnTransactionReadyToRead! #######");
HttpResponse* pHttpResponse = httpTransaction.GetResponse();
if (pHttpResponse->GetStatusCode() == NET_HTTP_STATUS_OK)
{
AppLog("%d",availableBodyLen);
HttpHeader* pHttpHeader = pHttpResponse->GetHeader();
String* tempHeaderString = pHttpHeader->GetRawHeaderN();
ByteBuffer* pBuffer = pHttpResponse->ReadBodyN();
String str((const char*)pBuffer->GetPointer());
AppLog("Response: %s",str.GetPointer());
int limit(pBuffer->GetLimit());
AppLog("Limit: %d",limit);
xmlDoc * doc = NULL;
xmlXPathContextPtr xpathCtx;
xmlXPathObjectPtr xpathtitle;
xmlXPathObjectPtr descriptionObj;
xmlXPathObjectPtr linkObj;
xmlXPathObjectPtr pubdateObj;
doc = xmlParseMemory((const char*)pBuffer->GetPointer(),pBuffer->GetLimit());// Here itself my code fails
if(doc==NULL)
{
flag1=1;
AppLog("Failed to load xml doc!");
xmlFreeDoc(doc);
xmlCleanupParser();
}
else
{
AppLog("InTo XML Parsing");
/* Create xpath evaluation context */
xpathCtx = xmlXPathNewContext(doc);
if(xpathCtx == NULL)
{
AppLog("Error: unable to create new XPath context");
xmlFreeDoc(doc);
}
/* Evaluate xpath expression */
xpathtitle = xmlXPathEvalExpression((xmlChar*)"//item/title", xpathCtx);
if(xpathtitle == NULL)
{
AppLog("Error: unable to evaluate xpath expression");
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
}
descriptionObj = xmlXPathEvalExpression((xmlChar*)"//item/description",xpathCtx);
if(descriptionObj == NULL)
{
AppLog("Error: unable to evaluate xpath expression");
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
}
linkObj = xmlXPathEvalExpression((xmlChar*)"//item/link",xpathCtx);
if(linkObj==NULL)
{
AppLog("Error: unable to evaluate xpath expression");
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
}
pubdateObj=xmlXPathEvalExpression((xmlChar*)"//item/pubDate",xpathCtx);
if(pubdateObj==NULL)
{
AppLog("Error: unable to evaluate xpath expression");
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
}
get_xpath_titles1(xpathtitle->nodesetval);
get_xpath_description1(descriptionObj->nodesetval);
get_xpath_link1(linkObj->nodesetval);
get_xpath_pubdate1(pubdateObj->nodesetval);
xmlFreeDoc(doc);
xmlCleanupParser();
delete tempHeaderString;
delete pBuffer;
}
}
else
{
flag1=1;
}
if(flag1==1)
{
pFormMgr->SendUserEvent(FormMgr::REQUEST_ID_ADD_FEED_FORM,null);
}
}
여전히 문제가 있습니까? –
@Circadian : 예 – ArulRaj