DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

45
kicks
published 4 months, 12 days ago, submitted by orca 4 months, 14 days ago

improve.dk — A simple fluent interface for creating XmlDocuments & strings.

Add a comment 9 comments | category: | Views: 5 | Get KickIt image code
tags: , , , , | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
Nice work. I always thought this was a bit more work than necessary. Have any thoughts on doing something for files and streams in System.IO?
posted by offwhite offwhite 4 months, 11 days ago
[comment removed]
posted by Ralph 4 months, 11 days ago
Granted is not the fastest or most efficient way, but it does look good and it seems allot more maintainable to me. Maybe if you have a 10MB xml file you should use XmlWriter, otherwise I would go with this fluent interface.

In the blog comments someone said : why not use link ? - I'm pretty sure you can't do this with link :

XmlOutput xo = new XmlOutput()
.XmlDeclaration()
.Node("root").Within()
.Node("numbers").Within();

for (int i = 1; i <= 10; i++)
xo.Node("number").Attribute("value", i.ToString()).InnerText("This is the number: " + i);
posted by sirrocco sirrocco 4 months, 11 days ago
damn ... we need some code tags :))
posted by sirrocco sirrocco 4 months, 11 days ago
[comment removed]
posted by Ralph 4 months, 11 days ago
Well, you might be familiar to the XmlWriter api, i'm not - so when looking at your code and his code, the wrapper looks nicer, and easyer to understand to me.

And i'm not really sure how many know the XmlWriter api so well that they would find hard to read and understand the fluent interface one.

Oh , and at the comment above when i kept writing "link" i meant "linq" :D
posted by sirrocco sirrocco 4 months, 11 days ago
Ralph,

I won't go ahead and say that this is a universal replacement for XmlWriter. XmlWriter definitely has it's merits, for instance if you're doing some large document XML handling. That being said, if you're not doing that, then maintanability and readability ought always be your primary concern, and imho, the XmlOutput method is a lot more readable.

Correct, not everyone will know the XmlOutput class, but most will find it easy to understand nonetheless. Furthermore, if we make it a requirement for everyone to know everything, why are we not writing x86 asm, after all that's somewhat easier to memorize than the .NET framework :)

And regarding the LINQ bit (which isn't actually LINQ, just a 3.5 feature, but everybody, including me, somehow manages to call it LINQ), I really despise the nestedness of it, the way any XML document creation will end with an ugly amount of closing paranthesises.

And finally, as I also mentioned on the blog, using XmlWriter inhibits you from accessing the underlying XmlDocument if needed.
posted by orca 4 months, 11 days ago
I also like the fact that it can be used 'fluently'. I prefer this approach then XmlTextwriter, but indeed, probably not that good performing. But then again, who cares about performance these days, right? :)
posted by TweeZz TweeZz 4 months, 11 days ago
<low whisper>I see winky people.</low whisper>
posted by powerrush powerrush 4 months, 11 days ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge