Is it a good practise to implement xml parsing in a state machine? If yes what are the major states we have to handle?
Share
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.
Well, if you’re writing your own parser “from scratch” – then you should probably make such kind of a sandwich:
So level 1 can (and should) be done in an FSM, I would do it with a set of states like Initial, InTagName, InAttrName, InAttrValue, InCDATA, etc. There won’t be too many, just a couple page switch statement.
Still, there’s still plenty of work in case you need correct schema/namespace/xpath/etc support.
So why not just take an existing solution?