首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

tinyXML链接疏失!11急

2012-07-31 
tinyXML链接出错!!!!!!!!!!!!11急急急!!!!!!最近在研究tinyxml操作XML文件,这是我的代码:(写的很乱,仅测试

tinyXML链接出错!!!!!!!!!!!!11急急急!!!!!!
最近在研究tinyxml操作XML文件,
这是我的代码:(写的很乱,仅测试用。。。)

C/C++ code
#include "tinyxml.h"#include <iostream>using namespace std;void main( int argc, char*argv[] ){    TiXmlDocument doc;    TiXmlElement* pmsg = NULL;    TiXmlDeclaration *pdecl = new TiXmlDeclaration( "1.0", "","");    if ( NULL ==pdecl )    {        return;    }    doc.LinkEndChild( pdecl );    TiXmlElement *pRoot = new TiXmlElement( "MyApp" );    if ( NULL ==pRoot )    {        return;    }    doc.LinkEndChild( pRoot );//¸ùÔªËØ    TiXmlComment *pComment = new TiXmlComment();    if ( NULL == pComment )    {        return;    }    pComment->SetValue( "Setting for MyApp" );    pRoot->LinkEndChild( pComment );    TiXmlElement *pMsgs = new TiXmlElement( "Messages" );    if ( NULL == pMsgs )    {        return;    }    pRoot->LinkEndChild( pMsgs );    pmsg = new TiXmlElement( "Welcome" );    pmsg->LinkEndChild( new TiXmlText( "Welcome to MyApp" ) );    pMsgs->LinkEndChild( pmsg );    pmsg = new TiXmlElement( "FaraWell" );    pmsg->LinkEndChild( new TiXmlText( "Thhank you for using MyApp" ) );    pMsgs->LinkEndChild( pmsg );    TiXmlElement *pWindows = new TiXmlElement( "Windows" );    pRoot->LinkEndChild( pWindows );//¸ùÔªËØÖвåÈëÐÂÔªËØWindows    pWindows->SetAttribute( "name", "MainFrame");    pWindows->SetAttribute( "x", 5 );    pWindows->SetAttribute( "y", 15 );    pWindows->SetAttribute( "w", 400 );    pWindows->SetAttribute( "h", 250 );    TiXmlElement *pCxn = new TiXmlElement( "Connection" );    pRoot->LinkEndChild( pCxn );    pCxn->SetAttribute( "ip", "192.168.0.1" );    pCxn->SetDoubleAttribute( "timeout", 123.456 );    //dump_to_stdout( &doc );    bool isOk = doc.SaveFile( "E:\\cjbtest\\TinyXMLdemo\\test1\\appsetting.xml" );    TiXmlDocument *pDocument = new TiXmlDocument( "E:\\cjbtest\\TinyXMLdemo\\test1\\appsetting.xml" );    if ( NULL != pDocument )    {        if ( !pDocument->LoadFile() )        {            return;        }        TiXmlElement *pRootElement = pDocument->FirstChildElement( "MyApp" );        if ( NULL != pRootElement )            {            TiXmlElement *pMsgElement = pRootElement->FirstChildElement( "Messages" );            if ( NULL != pMsgElement )                {                TiXmlElement *pWelElement = pMsgElement->FirstChildElement( "Welcome" );                if ( NULL != pWelElement )                {                 std::cout<<pWelElement->GetText()<<std::endl;                }                TiXmlElement *pFarawell = pWelElement->NextSiblingElement( "FaraWell" );                if ( NULL != pFarawell )                {                 std::cout<<pFarawell->GetText()<<std::endl;                }            }            else            {                return;            }            TiXmlElement *pWindowsElement = pMsgElement->NextSiblingElement( "Windows" );            if ( NULL != pWindowsElement )                {                TiXmlAttribute *pFistAttribute = pWindowsElement->FirstAttribute();                if ( NULL != pFistAttribute )                {                    std::cout<<pFistAttribute->IntValue()<<std::endl;                }                TiXmlAttribute *pSecond = pFistAttribute->Next();                if ( NULL != pSecond )                {                    std::cout<<pSecond->IntValue()<<std::endl;                }                TiXmlAttribute *pth = pSecond->Next();                if ( NULL != pth )                {                    std::cout<<pth->IntValue()<<std::endl;                }                TiXmlAttribute *pFouth = pth->Next();                if ( NULL != pFouth )                {                    std::cout<<pFouth->IntValue()<<std::endl;                }            }            else            {            }            TiXmlElement *pConnection = pWindowsElement->NextSiblingElement( "Connection" );            if ( NULL != pConnection )                {                TiXmlAttribute *pConFist = pConnection->FirstAttribute();                if ( NULL != pConFist )                {                    std::cout<<pConFist->Value()<<std::endl;                }                TiXmlAttribute *pConSec = pConFist->Next();                if ( NULL != pConSec )                {                    std::cout<<pConSec->DoubleValue()<<std::endl;                }            }            else            {                return;            }        }        else        {        return;        }    }} 





[解决办法]
一般可能是你的lib是debug版的所以只能用,而在主程序的release版下不成,反之亦然,请保证库文件和调用库文件的程序生成版本一致
[解决办法]
http://download.csdn.net/source/3246292
这个或许对你有帮助
[解决办法]
error LNK2001: unresolved external symbol ___security_cookie

这个问题据信是由于你的VC启用了/GS导致的,手动加入/GS-即可

http://www.pcreview.co.uk/forums/unresolved-external-symbol-___security_cookie-t1428747.html

热点排行