5 ms·
Yeah thats a nice xmldict you wrote there, except it doesnt do anything good at all. Try to parse this with it, <html>hello</lol>world</html>. So much for your
by ColdAsIce 15y ago
Yeah thats a nice xmldict you wrote there, except it doesnt do anything good at all. Try to parse this with it, <html>hello</lol>world</html>. So much for your A* search and algorithmic knowledge.
I am no good with algorithms but would know to stop at such an idea as to make my own xmldict parser in that way. I would instead learn about parsing and the algorithms for successful parsing, instead of a half-assed approach.
- lutorm 15y agoI don't know a lot about XML, but that doesn't look like (legal) XML to me. Is it?
- irahul 15y ago> Try to parse this with it, <html>hello</lol>world</html>. Parsing invalid xml with a xml parser throws an error like it should. I am using cElementTree for parsing and this is what will happen with your input. In [1]: import xml.etree.cElementTree as ElementTree In [2]: ElementTree.XML('<html>hello</lol>world</html>') --------------------------------------------------------------------------- ParseError Traceback (most recent call last) /home/rahul/musings/python/<ipython-input-2-54e782b0af58> in <module>() ----> 1 ElementTree.XML('<html>hello</lol>world</html>') /home/rahul/musings/python/<string> in XML(text) ParseError: mismatched tag: line 1, column 13 > make my own xmldict parser in that way What is that way you are talking about? There isn't a xmldict implementation for Python(at least I can't google it), I needed one, so I wrote a recursive descent parser. A recursive descent parser is a popular choice provided your grammar is LL(k) - Python, Perl et al run on hand-coded recursive-descent parsers. Also, recursive-descent parsers are easiest to handroll. PS - There is a way to disagree. Your's isn't the right way.