- 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
At least they'll be ready for parsing the resulting document in Perl with regexps.
Admin
I can forgive the roll your own XML generation, the strings being stored in non-const variables, the lack of support for deeper nesting... but if that indentation is done using spaces (and not tabs), I'm going to lose myself!!!!....
Admin
Just use XmlTextWriter, which has been in .NET since 1.1. It's a bit clunky to use, but it's there.
Admin
When you need a higher indent level, just use
space20 + space8
</sarcasm>Admin
They don't need to add a
space24
.Since they were foresighted enough to use variables than constant, they can just assign different values to
space4
,space8
, etc. when needed, and easily make the code worse to maintain.People can't expect decent retirement benefits nowadays, let's let them at least have enough bug to fix to provide job security.
Admin
Perl has some really good XML libraries (several for different purposes, including being able to pretty-print) so there's no excuse for trying to roll your own. That said, I have seen over the years plenty of random people attempt exactly that.
Admin
Not to mention the famous one where the programmer ends up summoning an eldritch horror :-)
Admin
I wanna be a pool developer when I grow up
Admin
That they've got libraries that do the job right is unsurprising. That that is no barrier to people doing the absolutely worst option available is also unsurprising, given where we are.
Admin
"pool developer"
Do they use poolean variables when doing deep dives into H2O(n) algorithms?
Admin
One of these days someone should teach computers how to iterate so we wouldn't need variables (or constants) like these.
Admin
Search and replace all the space_nn usages with
new String(' ', nn);
Admin
I have done the roll-your-own-XML in C# before.
It was faster and easier to do a bunch of StringBuilder.AppendFormat calls than it was to use the built-in XML stuff. But I did not try to prettyprint the thing.
Under the same circumstances, I'd do it again.
Admin
I had a coworker who generated XML files with strings in VB.NET.
I started providing him with a class library DLL that would parse/generate the XML serialization for specific classes for him so all he had to do was call a function. I had written that code anyway for my own use in my own app.
PS: Google login is broken here.
Admin
Same.
As long as it is purely writing, and no occurences of awkward string escaping in the data, creating an XML document by string operations is not only entirely feasible, but can easily produce more readable code than doing DOM manipulation, AND have better performance.
Admin
There is actually no build in XML stuff, there are techincally three :-)
I agree that those Java inspired old .net 1.0 XML implementions based on COM+ around XmlDocument and so on can be slow, especially if you don't use them correctly. However compared to what you got in Java 20 years ago, they were unbelievable fast and implemented the complete standard, which is super complex as soon as you include namespaces.
While .net was built on XML literally it has fallen on the side over years, not because it's bad, but more because developers are bad and that resulted in the opposite intention of having a lightweight (yes, I am not kidding here, compared to similar concepts for data transfers, it was actually built to not have a tons of use case specific rules and hundreds of pages of specs for stuff you nver going to need, but a general purpose extendable format which could define itself via schemas) format for data transfer operations. So modern .net Versions mostly use JSON which is basically a text version of a binary blob.
Admin
Rolling your own "XML writer" is also the most convenient choice when your XML consumption counterpart expects some kind of stupidly malformed (or even broken) XML (as in, "this bug is now a feature", "programs expect it the wrong way", etc.), when the builtin methods or library-provided tools will only produce correct XML that "doesn't work". Yes, such crazy things exist. They sometimes look like this: <data <item 1>123</item 1> , <item 2>A->B </item 2> , <item 3>undefined</> EOF.
Admin
I'm pretty disappointed they didn't have space1999.
Admin
Just came across a similar bug on a major price-comparison website.
Noticed when I tried to scrap the site with Google Sheets, where my code balked at the malformed tag due to the spurious unescaped double-quote.