﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-bingxuefly-最新评论</title><link>http://www.cnblogs.com/bingxuefly/CommentsRSS.aspx</link><description /><language>zh-cn</language><pubDate>Sun, 13 Nov 2011 04:04:24 GMT</pubDate><lastBuildDate>Sun, 13 Nov 2011 04:04:24 GMT</lastBuildDate><generator>cnblogs</generator><item><title>Re:VC解析XML--使用CMarkup类解析XML</title><link>http://www.cnblogs.com/bingxuefly/archive/2011/08/17/724318.html#2178937</link><dc:creator>likebeta</dc:creator><author>likebeta</author><pubDate>Wed, 17 Aug 2011 01:28:44 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2011/08/17/724318.html#2178937</guid><description><![CDATA[谢谢楼主了，我去试试，用他操作html可以吗？<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">likebeta</a> 2011-08-17 09:28 <a href="http://www.cnblogs.com/bingxuefly/archive/2011/08/17/724318.html#2178937#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:VC解析XML--使用CMarkup类解析XML</title><link>http://www.cnblogs.com/bingxuefly/archive/2011/03/11/724318.html#2044475</link><dc:creator>清清飞扬</dc:creator><author>清清飞扬</author><pubDate>Fri, 11 Mar 2011 08:03:51 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2011/03/11/724318.html#2044475</guid><description><![CDATA[我用你同样的代码，在进行了添加元素后，再调用更新元素时，在Load处就失败了，加载不成功!不知道是哪里的问题？


[code=cpp]
void CXml_MarkupDlg::OnBtnFind() 
{
	CMarkup xml;
	if(!xml.Load(&quot;D:\\Desktop\\dd\\a.xml&quot;))
	{
		MessageBox(&quot;加载文件失败，请确认文件是否存在&quot;);
		return;
	}
	CString sResult;
	while(xml.FindChildElem(&quot;ITEM&quot;))
	{
		xml.IntoElem();							// 进入当前结点
		xml.FindChildElem(&quot;SN&quot;);
		CString sSN = xml.GetChildData();
		xml.FindChildElem(&quot;NAME&quot;);
		CString sName = xml.GetChildData();
		xml.FindChildElem(&quot;QTY&quot;);
		int nQty = atoi(xml.GetChildData());
		xml.OutOfElem();						// 退出当前结点

		sResult.Format(&quot;%s, %s, %d&quot;, sSN, sName, nQty);
		MessageBox(sResult);
	}
}

void CXml_MarkupDlg::OnBtnAdd() 
{
	CString sFileName = &quot;D:\\Desktop\\dd\\a.xml&quot;;
	CMarkup xml;
	if(!xml.Load(sFileName))
	{
		MessageBox(&quot;加载文件失败，请确认文件是否存在&quot;);
		return;
	}

	xml.AddElem(&quot;ORDER&quot;);
	xml.IntoElem();
	xml.AddElem(&quot;ITEM&quot;);
	xml.IntoElem();
	xml.AddElem(&quot;SN&quot;, &quot;4238764-A&quot;);
	xml.AddElem(&quot;NAME&quot;, &quot;bearing&quot;);
	xml.AddElem(&quot;QTY&quot;, &quot;15&quot;);
	xml.OutOfElem();

	xml.AddElem(&quot;SHIPMENT&quot;);
	xml.IntoElem();
	xml.AddElem(&quot;POC&quot;);
	xml.SetAttrib(&quot;type&quot;, &quot;non-emergenty&quot;);
	xml.IntoElem();
	xml.AddElem(&quot;NAME&quot;, &quot;John Smith&quot;);
	xml.AddElem(&quot;TEL&quot;, &quot;555-1234&quot;);
	xml.Save(sFileName);
}

void CXml_MarkupDlg::OnBtnUpdate() 
{
	CString sFileName = &quot;D:\\Desktop\\dd\\a.xml&quot;;
	CMarkup xml;
	if(!xml.Load(sFileName))
	{
		MessageBox(&quot;加载文件失败，请确认文件是否存在&quot;);
		return;
	}
	if(xml.FindChildElem(&quot;SHIPMENT&quot;))
	{
		xml.IntoElem();
		if(xml.FindChildElem(&quot;POC&quot;))
		{
			xml.IntoElem();
			CString sType = xml.GetAttrib(&quot;type&quot;);
			MessageBox(sType);
			xml.SetAttrib(&quot;type&quot;, &quot;change&quot;);
			CString sUserID = xml.GetData();
			MessageBox(sUserID);
			if(xml.FindChildElem(&quot;TEL&quot;))
			{
				xml.IntoElem();
				xml.SetData(&quot;123456789&quot;);
				xml.Save(sFileName);
			}
		}
	}
}
[/code]

最初的xml文件内容是：
&lt;ORDER&gt;
&lt;ITEM&gt;
	&lt;SN&gt;132487A-J&lt;/SN&gt;
	&lt;NAME&gt;crank casing&lt;/NAME&gt;
	&lt;QTY&gt;1&lt;/QTY&gt;
&lt;/ITEM&gt;
&lt;ITEM&gt;
	&lt;SN&gt;132487B-K&lt;/SN&gt;
	&lt;NAME&gt;crank cafe&lt;/NAME&gt;
	&lt;QTY&gt;2&lt;/QTY&gt;
&lt;/ITEM&gt;
&lt;/ORDER&gt;<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">清清飞扬</a> 2011-03-11 16:03 <a href="http://www.cnblogs.com/bingxuefly/archive/2011/03/11/724318.html#2044475#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:VC解析XML--使用CMarkup类解析XML</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/10/25/724318.html#1942386</link><dc:creator>飞鸽传书官方网站</dc:creator><author>飞鸽传书官方网站</author><pubDate>Mon, 25 Oct 2010 03:37:30 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/10/25/724318.html#1942386</guid><description><![CDATA[好文章。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">飞鸽传书官方网站</a> 2010-10-25 11:37 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/10/25/724318.html#1942386#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:#pragma pack() 和sizeof</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/08/23/957056.html#1900014</link><dc:creator>飞天名猪</dc:creator><author>飞天名猪</author><pubDate>Mon, 23 Aug 2010 09:08:12 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/08/23/957056.html#1900014</guid><description><![CDATA[编译器好像没有5字节对齐，只有双数的。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">飞天名猪</a> 2010-08-23 17:08 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/08/23/957056.html#1900014#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:#pragma pack() 和sizeof</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/08/21/957056.html#1898757</link><dc:creator>刘林</dc:creator><author>刘林</author><pubDate>Sat, 21 Aug 2010 08:08:48 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/08/21/957056.html#1898757</guid><description><![CDATA[还想问一下，如果
#pragma pack(push) //保存对齐状态
#pragma pack(5)      //设定为5字节对齐
struct test {
char m1;
double m4;
int m3;
};
#pragma pack(pop)//恢复对齐状态

test t ={1, 2, 3};

设置成5字节对齐的时候，此时我查看t的内存，t中double的成员变量为什么在内存中看不出来，还有对齐方式也看不出来是5的倍数，不知道编译器是怎么优化的。
Memory1中是这么显示的：
01 cc cc cc cc cc cc cc [b]00 00 00 00 00 00 14 40[/b] 03 00 00 00 cc cc cc cc
我只看到1和3，2不知道是怎么搞的。
楼主能不能解释一下。
MAIL: liuling-1985@163.com
<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">刘林</a> 2010-08-21 16:08 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/08/21/957056.html#1898757#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:#pragma pack() 和sizeof</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/08/21/957056.html#1898754</link><dc:creator>刘林</dc:creator><author>刘林</author><pubDate>Sat, 21 Aug 2010 08:03:01 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/08/21/957056.html#1898754</guid><description><![CDATA[好文章，写得很详细。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">刘林</a> 2010-08-21 16:03 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/08/21/957056.html#1898754#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:发布9个腾讯微博的邀请码</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/06/07/1748775.html#1841827</link><dc:creator>飞天名猪</dc:creator><author>飞天名猪</author><pubDate>Mon, 07 Jun 2010 02:11:33 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/06/07/1748775.html#1841827</guid><description><![CDATA[再发8个
http://t.qq.com/invite/11e89cddb39677fb3bc7
http://t.qq.com/invite/e903561d3bc7d2ea78eb
http://t.qq.com/invite/e1d2e154b9103b586933
http://t.qq.com/invite/33bfdbabd0c43c0a966b
http://t.qq.com/invite/a78e8ea57bf1109052e3
http://t.qq.com/invite/69100d6225d9d5b37313
http://t.qq.com/invite/2d77639a0b120fca3481
http://t.qq.com/invite/699c0f40a756c97a1ddb
http://t.qq.com/invite/e9be4941253646ca4fc3<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">飞天名猪</a> 2010-06-07 10:11 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/06/07/1748775.html#1841827#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:发布9个腾讯微博的邀请码</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837366</link><dc:creator>kuafoo</dc:creator><author>kuafoo</author><pubDate>Tue, 01 Jun 2010 01:22:03 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837366</guid><description><![CDATA[http://t.qq.com/invite/daa4dc69ef5a295d5d85
http://t.qq.com/invite/2575fe632a21fd92cedf
http://t.qq.com/invite/4c96c999d0b16cf4d031<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">kuafoo</a> 2010-06-01 09:22 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837366#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:发布9个腾讯微博的邀请码</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837364</link><dc:creator>Q</dc:creator><author>Q</author><pubDate>Tue, 01 Jun 2010 01:21:21 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837364</guid><description><![CDATA[还有吗？<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">Q</a> 2010-06-01 09:21 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837364#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Re:发布9个腾讯微博的邀请码</title><link>http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837333</link><dc:creator>寒萧</dc:creator><author>寒萧</author><pubDate>Tue, 01 Jun 2010 01:00:04 GMT</pubDate><guid>http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837333</guid><description><![CDATA[谢谢，用了一个<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/bingxuefly/" target="_blank">寒萧</a> 2010-06-01 09:00 <a href="http://www.cnblogs.com/bingxuefly/archive/2010/06/01/1748775.html#1837333#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>
