Currently this would be a sample XML that I am working on:
<smsq>
<sms>
<id>96</id>
<to>03333560511</to>
<msg> danial says: hahaha <space> nothing.
</msg>
</sms>
</smsq>
Now please notice, that the tag can contain other tags (which should not be parsed) and I had to make a dtd for that. The dtd was something like this:
<!DOCTYPE smsq [
<!ELEMENT sms (mID,to,msg,type)>
<!ELEMENT mID (#PCDATA)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT msg (CDATA)>
]>
But the problem is that XML parser still goes in the tag and says that the tag should be closed with a tag. I just want to fetch the data as it is from the XML and I do not want to parse msg further.
Please help me resolve the problem and tell me if this can be done with DTDs.
Thanks!
Firstly the sample xml is not really xml as the “space” tag is not closed.
Secondly, it looks like the reason for not wanting to parse the “space” tag is because it’s not really xml – just text that looks like xml. The text should be either escaped/encoded or enclosed in CDATA tags.
Lastly – if what you want to parse really is xml and you only want to parse the first level tags. I wouldn’t bother with a real XML parser – i’d create my own ultra-simple parser – all it has to do is parse 1st level nodes – that shouldn’t be too hard.
Good luck!