Unit testing XML Generation [closed]

First, as pretty much everyone is saying, validate the XML if there’s a schema defined for it. (If there’s not, define one.) But you can build tests that are a lot more granular than that by executing XPath queries against the document, e.g.: string xml=”Your xml string here” ; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); … Read more

Use of XSL-FO, CSS3 instead of CSS2 to create Paginated documents like PDF?

Thanks all comments and answers! Now, 2014, passed over 1.5 years of my post (May 17 ’12), is time to consolidate: no answer was, for me, a “full answer”, but all answers (see Nenotlep’s and Alex’s) contributed to form a big picture. My main motivation now, to consolidate, is the @mzjn’s news (here) of 2013-11. … Read more

Empty namespace using Linq Xml

The “more correct way” would be: XDocument xdoc = new XDocument(new XDeclaration(“1.0”, “utf-8”, “true”), new XElement(ns + “urlset”, new XElement(ns + “url”, new XElement(ns + “loc”, “http://www.example.com/page”), new XElement(ns + “lastmod”, “2008-09-14″)))); Same as your code, but with the “ns +” before every element name that needs to be in the sitemap namespace. It’s smart … Read more

How can I check for the existence of an element with Groovy’s XmlSlurper?

The API is a little screwy, but I think that there are a couple of better ways to look for children. What you’re getting when you ask for “xml.bar” (which exists) or “xml.quux” which doesn’t, is a groovy.util.slurpersupport.NodeChildren object. Basically a collection of nodes meeting the criteria that you asked for. One way to see … Read more