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 ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
myStringto the code below:Disclaimer 2: You really should use an XML parser library instead.