- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Brillant.
Admin
But, but, what if someone uses gasp ...
[ <tag> s p a c e s </tag> ]
?
Admin
<comment>This will never work</comment>
Admin
My eyes! The goggles do nothing!
Admin
Not only on one line, they also have to be in order. "But... we've got XML!"
Admin
this is arguably better than the second link in the article. UGH
captcha: consequence
Admin
<xmlcomment1>Efficient XML '</xmlcomment1> <xmlcomment2></xmlcomment2> <xmlcomment3></xmlcomment3> <xmlcomment4></xmlcomment4> <xmlcomment5></xmlcomment5> <xmlcomment6></xmlcomment6> <xmlcomment7></xmlcomment7> <xmlcomment8></xmlcomment8> <xmlcomment9></xmlcomment9> <xmlcomment10></xmlcomment10> <xmlcomment11></xmlcomment11> <xmlcomment12></xmlcomment12> <xmlcomment13></xmlcomment13> <xmlcomment14></xmlcomment14> <xmlcomment15></xmlcomment15> <xmlcomment16></xmlcomment16> <xmlcomment17></xmlcomment17> <xmlcomment18></xmlcomment18> <xmlcomment19></xmlcomment19> <xmlcomment20></xmlcomment20>
Admin
I particularly liked the sNot variable, although here I think they've got the case-sensitivity wrong.
Admin
How can you like the sNot variable and miss the sExact variable entirely!!!
Its far more promiscuous
Admin
Is it me, or is this thing not even valid XML since it's missing the root node?
Admin
Sorry, i missed the sLine... that one's probably the root and the closing tag is just ignored :P
Admin
If I'm groking the code right, then sLine is only read in order to get the "root" element.
Admin
It's sNot XML...
Admin
Admin
This was clearly done with the intention of being more efficient than a regular xml parser. So the real wtf is:
instead of
Way more efficient, and more readable.
Admin
Admin
"If you consider yourself a senior level xml developer" - you'll be happy to know you can go for a promotion - they have a junior level VB developer position opening tomorrow.
Admin
Admin
To be fair, all XML-parsing techniques are Case-Sensitive, because XML itself is.
Admin
Looks to me like a classic case of notimeleft programming to me. You've tried to use XML libraries, haven't understood, or been hit by strangeness (PHP XML libraries, anyone?). So you realise that the file is standard, and is only being done in XML because someone thought it should be. So you write a piece of crap which parses the file as you need it.
CSV would have been adequate here, since there probably isn't anyone else trying to parse the same XML file.
TRWTF is that the file to be parsed was in XML in the first place.
Admin
Hey, thanks for posting that, I got to tell you that this guy was a relative of the big boss, and we had some difficulties letting him go, he did eventually. He keeps on calling me trying to get his job back.
The whole program never worked and was re-written from scratch few month after. sNot as a variable name is cool.
Admin
It just needs a little more work to be perfect:
And so on...
Admin
</exact>Do<exact> </not>valid<not> </case>xml<case> </condition>,<condition> </position>Yoda<position> </action>can..<action>
Admin
MERYL, how do I do XML? grumble
Admin
Admin
I still prefer the method my ex-employer used to parse XML files. A "spider" would crawl the document tree, parsing "unwieldy" XML like this:
into the much more readable:
Admin
"there was Something there in the air there in tonight"
is not more readable than
"there was Something was in the air tonight in there"
Admin
Admin
Admin
The SimpleXML library is pretty awesome, though.
Admin
This one wins hands-down on WTF-iness over my first "SOAP Parser". It actually used the XML Parser implementation in Java ... then discarded the whole SOAP metadata and extracted only the contents. And expected only certain tags. Look at it cross-eyed and it would barf. Ow!
Admin
Admin
I'll bet the guy who created XPATH is feeling pretty silly right about now
Admin
Which was pretty much my point. It's a pointless parsing step that, if anything, makes parsing slower and just provides more opportunities for things to go wrong.
Admin
If this piece of code worked, then surely the real WTH is why the file is created using XML to begin with. If the file always consists of the same five data elements in a fixed order, what possible gain was there from wrapping them in XML? Besides, that is, to satsify some simpleminded rule that all data streams must be in XML.
This is the same objection I have to about 90% of the uses of XML. Yes, if you have a very complex data stream, where data elements car occur in unpredictable order, and data elements can be embedded inside other data elements, then XML is beautiful. Like, say, in a word processing document, where the user could at any point want to insert italics or a footnote or a footnote with italics.
But how did we get from, "This tool is useful for a small class of complex problems, where there is no simple solution and so we must use a complex solution," to "Let's use an awkard, complex solution for even the most simple problems!" Yes, it can be made to work, but the price is huge for what benefit?
When Exxon writes a multi-billion dollar oil contract with Saudi Arabia, I'm sure they need a team of engineers and geologists and lawyers and linguists and cross-cultural specialists to get it all hammered out. It's a complicated process that requires a complicated solution. Does this mean that I should bring such a team with me to McDonald's to write a contract for me to buy a hamburger? If it works for Exxon, it should work for me, right?
Admin
Admin
Don't forget XQuery.
Admin
Even if we give this guy the benefit of the doubt and we assume that this XML was forced on him, it's still a really stupid way to do this. For the record, I suggest:
Admin
This is why you should store data in an XLS file, not XML.
Admin
Admin
Admin
For a lot of cases, it's easier to use a xml parser/emitter that it is to come up with some sort of file format.
Admin
So if they were to create a string with the exact position, would they name it sExPosition?
Admin
Okay, I'm feeling very stupid right now! I don't understand what the goal of this program was.
From what I can see, it's just stripping out XML tags. How does that help parse the data within? Wouldn't this, in fact, make it impossible to parse the data?
Or did I forget to take my common-sense pills again?
Admin
I'm sure he'll do ok, I heard he's helping a computer system called GW, for a company named Outer Haven...
Admin
...helping develop
Admin
Imagine XML input
After running the program, you have sExact = "maybe" sNot = "so" sCase = "eh?" sCondition = "chronic" sPosition = "onTop" sAction = "ooh,err?"
So, it's an XML parser. Much more compact than the other things you'll find around, and it works perfectly...
;)
Admin
I'm gonna gouge out my eyes and go cry myself to sleep now.
Admin
You could just convert the XML to JSON and then strip out the brackets and curly braces.
Admin
I'm not suggesting that one should invent an entirely new formatting scheme for every problem. Rather, that one should use simple formats for simple problems and reserve complex formats for complex problems.
I think a very large set of problems could be solved with CSV, Java properties files, and Web form variables. And those are all way simpler for a human reader to comprehend, and can be parsed with a few lines of code. Sure, I can use a Saxon library or whatever to parse XML, it's not likely I have to write a parser from scratch. But that's like saying, Hey, it doesn't matter that the door to our store is 30 feet off the ground: we're happy to provide anyone who asks with a ladder.