1

I have a char array and the text actually looks like XML:

<root>
<number>1</number>
<counter>2</counter>
<lastNumber>3</lastNumber>
</root>

I need to get these values and store them to variables so I can work with them.

Any idea how to do that?

Thank you

3
  • 9
    Use an xml library? Commented Jan 9, 2013 at 22:05
  • That doesn't look like a char array at all, it looks a lot like XML... Commented Jan 9, 2013 at 22:05
  • why not just use regexp? Commented Jan 9, 2013 at 23:04

2 Answers 2

6

You could use TinyXML, to parse the file. http://www.grinninglizard.com/tinyxml/ Its a open source library to parse XML files in C++.

Sign up to request clarification or add additional context in comments.

Comments

2

You should formulate a better question, but the general idea is clear and so I suggest to use a library such as boost::spirit or, if you can arrange your data in a different way, you can use boost::config which is probably a much simpler approach and here is an example .

2 Comments

boost::spirit for writing yet another xml parser? No way, unless you are doing homework. There are bunch of production-ready xml parsers to use, so leave boost::spirit for really new languages.
@hate-engine all you can say right now it's that the OP needs to parse a file, no reference about any XML specific schema or DTD of any kind, in this case, generic case, boost::spirit is the only way to go, also there are many case where the word XML it's not enough, there are many schemas for XML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.