提取标签之间的 CString
如何提取两个标签之间的 CString ?
<tag1>My Text</tag1>
我不想计算开始和结束位置然后使用 Mid,也许还有另一种更简单的方法使用 STL ?
How can I extract a CString between two tags ?
<tag1>My Text</tag1>
I don't want to calculate the start and end position then use Mid, maybe there is another easier method using STL ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
免责声明:以下想法不好 和不应在生产代码中使用。我假设您只是想要快速进行测试。
使用正则表达式来匹配标签。 Microsoft 在 CAtlRegExp 中提供了此功能。如果您使用的是 Visual Studio 2008 或更高版本,请在此处下载 ATL。然后,只需将
myString
提供给以下代码:免责声明 2:您确实应该使用 改为 XML 解析器库。
Disclaimer: the following idea is bad and should not be used in production code. I'm assuming you just want a quick hack for testing.
Use a regular expression to match the tags. Microsoft provides this in CAtlRegExp. If you're using Visual Studio 2008 or newer, download ATL here. Then, just provide
myString
to the code below:Disclaimer 2: You really should use an XML parser library instead.