Skip to content
Advertisement

Exclude blank columns from XML

I am trying to get Table Rows to XMLs. I am able to do it in the following way and the only issue I have is that it also generates XML tags for blank columns.

Output XML:

Expected XML:

Any help will be appreciated. Thanks

Advertisement

Answer

You could just use nullif() to turn empty strings to nulls in the second column:

Demo on DB Fiddle:

| xmlelement                      |
| :------------------------------ |
| <Root><x>1</x><y>ABC</y></Root> |
| <Root><x>2</x></Root>           |
| <Root><x>3</x></Root>           |
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement