24,854
社区成员
发帖
与我相关
我的任务
分享
<cameras>
<camera ip="192.127.66.98" id="b16f71e0-ffff-ffff-bf36-9d863ee5445" status="0" hasptz="0"/>
<camera ip="192.127.66.99" id="b16f71e0-ffff-ffff-bf36-9d863ee5446" status="0" hasptz="0"/>
<camera ip="192.127.66.100" id="b16f71e0-ffff-ffff-bf36-9d863ee5447" status="0" hasptz="0"/>
</cameras>
strip=xml.GetChildAttrib("ip");
strid=xml.GetChildAttrib("id");
xml.FindChildElem( "ip" );
cout<<"strip="<<strip<<endl;
cout<<"strid="<<strid<<endl;
xml.OutOfElem();
CMarkup xml;
//bool flag;
xml.Load(_T("F:\\1.xml"));
xml.ResetMainPos();
string strFindcamera;
//xml.FindElem();
//xml.IntoElem(); //进入根节点
while (xml.FindElem("cameras"))
{
xml.FindChildElem("camera");
if (xml.GetChildData()==strFindcamera)
{
string strip;
string strid;
strip=xml.GetChildAttrib("ip");
strid=xml.GetChildAttrib("id");
g_CameraInfo.insert(pair<string,string>(strip,strid));
}
}
版主,再次打扰你下,我看了那个网站,然后写了上面的代码,但现在还是只能获取单个IP和ID,循环一次就断了,最近才用这个,恳请版主空闲的时候帮我看看,不甚感激!谢谢版主![/quote]
你运行一下他的例子,看有没有问题CMarkup xml;
//bool flag;
xml.Load(_T("F:\\1.xml"));
xml.ResetMainPos();
string strFindcamera;
//xml.FindElem();
//xml.IntoElem(); //进入根节点
while (xml.FindElem("cameras"))
{
xml.FindChildElem("camera");
if (xml.GetChildData()==strFindcamera)
{
string strip;
string strid;
strip=xml.GetChildAttrib("ip");
strid=xml.GetChildAttrib("id");
g_CameraInfo.insert(pair<string,string>(strip,strid));
}
}
版主,再次打扰你下,我看了那个网站,然后写了上面的代码,但现在还是只能获取单个IP和ID,循环一次就断了,最近才用这个,恳请版主空闲的时候帮我看看,不甚感激!谢谢版主!CMarkup xml;
//bool flag;
xml.Load(_T("F:\\1.xml"));
xml.ResetMainPos();
string strFindcamera;
//xml.FindElem();
//xml.IntoElem(); //进入根节点
while (xml.FindElem("cameras"))
{
xml.FindChildElem("camera");
if (xml.GetChildData()==strFindcamera)
{
string strip;
string strid;
strip=xml.GetChildAttrib("ip");
strid=xml.GetChildAttrib("id");
g_CameraInfo.insert(pair<string,string>(strip,strid));
}
}
版主,再次打扰你下,我看了那个网站,然后写了上面的代码,但现在还是只能获取单个IP和ID,循环一次就断了,最近才用这个,恳请版主空闲的时候帮我看看,不甚感激!谢谢版主![/quote]
你运行一下他的例子,看有没有问题[/quote]已经解决了,谢谢版主及楼上的各位
To find the item with a particular serial number, you can loop through the ITEM elements and compare the SN element data to the serial number you are searching for. By specifying the "ITEM" element tag name in the FindElem method we ignore all other sibling elements such as the SHIPMENT element. Also, instead of going into and out of the ITEM element to look for the SN child element, we use the FindChildElem and GetChildData methods for convenience.
xml.ResetPos(); // top of document
xml.FindElem(); // ORDER element is root
xml.IntoElem(); // inside ORDER
while ( xml.FindElem("ITEM") )
{
xml.FindChildElem( "SN" );
if ( xml.GetChildData() == strFindSN )
break; // found
}