Contents tagged with Xml

  • And that is 2013

    I’ve been blogging for a couple of years now and although I’ve never been a prolific blogger (and never will!), I like to get at least one post out a month. However next year I’m going to try to up my game a little with a couple of ideas that I've got to try and take my blog and contribution up a notch. There are very few things that are certain for everybody in life, and one of those is change. We all must change and embrace change to stay fresh and if you don’t change …

  • Removing HTML formatting tag - BR - from XML using XQuery

    This is a personal pet hate of mine.. Mixing HTML formatting tags directly with XML that aren’t escaped or contained within a CDATA section. Sure it is all perfectly valid XML at the end of the day, but it makes working with it a bit harder as each section of text between each <BR/> tag is treated as a separate text node and has to be factored into any schema for that XML structure.

    I’ve been working on an XML migration project recently that has a lot of this going on. Data …

  • Retrieving the next or previous element node value in an Xml blob using XQuery

    It’s been a little while since I wrote a blog post on my favourite subject but this is from a thread on the SSC Xml forum that I was helping out on a couple of weeks ago. I’ve been a bit busy lately with a big project at work, revising/taking exam 70-461 and getting ready for the birth of my second child! But this thread seemed too good a subject for me to miss quickly get a post out showing how I might approach this particular problem.

    Sometimes we are given a pretty poorly …

  • Using XQuery to remove duplicate values or duplicate nodes from an xml instance

    Sometimes we need to retrieve a list distinct values from within an xml instance or even distinct nodes and this is relatively straight forward using XQuery. It gets a bit more complicated if you have attributes in the xml, but it is still possible to retrieve unique xml nodes. On the flip side, it is also possible to only return xml nodes that are duplicated in the xml instance. All the examples can be downloaded here

    Retrieving Distinct Values

    Getting a list of distinct atomic values from a …

  • Suppressing namespace attributes in nested select statements when using FOR XML workaround

    I was helping out on the forums the other day with a user who had stumbled across the quirk of SQL putting in an excessive amount of namespace declarations when using nested select statements as part of a FOR XML statement. There is a connect item already open for this, but at the end of the day, the output from SQL is correct, it just bloats the xml. Attached to the connect item is a link to a workaround but it doesn’t work for me as it only solves the problem if none of the xml nodes or …

  • Using XQuery to transform multiple xml nodes to a single xml node with comma separated string value

    Not another comma separated string blog post I hear you say! I know that this topic has probably been done to death but I hope that this is a little different as it is about creating a single xml node containing a comma separated string from the values of multiple other xml nodes all within an XQuery expression.

    Recently I’ve been working on some xml migrations using XQuery and one of the many types of transformations that I had to do was to take a number of identically named xml nodes …

  • Moving xml child elements to its parent using XQuery

    I haven’t been able to do much XQuery development recently which is a shame as I love developing with the technology in SQL. In the past I used to work with xslt’s a lot and they immensely powerful, but since moving to xquerying in SQL, it is now my first choice for quick xml transformations. Especially if the XML is already stored within the database and not externally.

    Lately though I have been involved in a data migration which also involved the transformation of a number of xml …

  • Shredding a simple xml structure to a single row flat table

    I was helping out a user on the forums the other day where they were asking questions about shredding an xml structure of which they didn’t know the schema for. They wanted to know the best way about writing a generic function to shred any xml to a flat table. In the past I have used the XMLTable function developed and blogged by Jacob Sebastian to shred an xml structure and suggested this as a starting place for them. After posting that comment, it did get me thinking though that I could …

  • Introduction to XML DML (Part 3) - Using the modify() method: delete

    This is the last part of a 3 part blog which will attempt to show some different ways of how you can use the xml modify() method to update the contents of an XML document. This part, starting at the absolute basics, will cover the ability to delete data in an existing XML document

    XML DML is an extension of the XQuery language that allows us to do in place updates of the contents of an XML document. XML DML is very flexible and most scenarios can be dealt with quite nicely with the use of the …

  • Introduction to XML DML (Part 2) - Using the modify() method: replace value of

    This is the second part of a 3 part blog which will attempt to show some different ways of how you can use the xml modify() method to update the contents of an XML document. This part, starting at the absolute basics, will cover the ability to update data in an existing XML document

    XML DML is an extension of the XQuery language that allows us to do in place updates of the contents of an XML document. XML DML is very flexible and most scenarios can be dealt with quite nicely with the use of …

  • 1
  • 2