Home Forums SQL Server 2008 T-SQL (SS2K8) How can I add encoding in output XML file like "<?xml version="1.0" encoding="ISO-8859-1"?>" RE: How can I add encoding in output XML file like "<?xml version="1.0" encoding="ISO-8859-1"?>"

  • Without knowing the details of the method you're using to generate said XML, it's hard to make a good choice about how best to go about it. If the XML you generate already has a record that might need to be replaced with the text you're looking for, that's a somewhat different problem from just adding this text at the beginning. Assuming you can at least get the XML text as individual records in some fashion (they don't need to be the XML data type, and plain old varchar or nvarchar would actually be preferable), then you can just:

    SELECT '<?xml version="1.0" encoding="ISO-8859-1"?>' AS XML_TEXT

    UNION ALL

    SELECT XML_TEXT

    FROM XML_RECORDSET

    You'll have to supply the field name instead of XML_TEXT as well as the table name for your recordset. If you need to filter out the other text, then you'd need the recordset creation process to do that part of it. Assuming a recordset gets created, you might be able to just filter on the text value.

    Can you provide more details on how this XML is being generated?

    If you're just needing to a

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)