C++操作XML之创建(1) (二)

2014-11-24 12:34:48 · 作者: · 浏览: 1
me,myPhone);

string friName;

string friPhone;

string friAttri;

int i = 1;

while(1)

{

cout<<"********************"<

XMLElement *friXMLElement = new XMLElement();

cout<<"请输入好友"<

getline(cin,friName);

if(friName=="0")

break;

cout<<"请输入他(她)的电话号码:";

getline(cin,friPhone);

cout<<"属性为:";

getline(cin,friAttri);

string name ="好友";

name += (char)(i+'0');

friXMLElement->setElementName(name);

friXMLElement->setAttribute(friName,friPhone);

friXMLElement->setTextNode(friAttri);

//cout<getMyInfo()<

myXMLElement.addSubElement(friXMLElement);

i++;

}

cout<<"我的通讯录为:"<

//cout<

//cout<

cout<

cout<

system("pause");

return 0;

}

------------------------------------------------程序测试-----------------------------------------------------

请输入自己的名字:heyong

请输入自己的电话号码:1455

********************

请输入好友1的名字(以0结束):liudehua

请输入他(她)的电话号码:1345

属性为:friend

********************

请输入好友2的名字(以0结束):zhangxueyou

请输入他(她)的电话号码:1873

属性为:friend

********************

请输入好友3的名字(以0结束):liming

请输入他(她)的电话号码:1890

属性为:friend

********************

请输入好友4的名字(以0结束):guofucheng

请输入他(她)的电话号码:1876

属性为:friend

********************

请输入好友5的名字(以0结束):0

我的通讯录为:

<我的通讯录heyong="1455">

<好友1 liudehua="1345">friend

<好友2 zhangxueyou="1873">friend

<好友3 liming="1890">friend

<好友4 guofucheng="1876">friend

请按任意键继续. . .

作者heyongluoyao8