Remove XML Tags with White space.

Hi All, I have a scenario like the below code where I have empty spaces in few columns of my tables. I create XML of the data and send it. There is a lot of code such and I can't add ISNULL() on each and every column. Is there any simple one line code working
with the XML so that I can remove the tags with only empty spaces. TIA.
DECLARE @xml1 VARCHAR(max)
DECLARE @xml2 VARCHAR(max)
set @xml1 = (SELECT 1 AS Col11, ' ' AS Col21, 'ABC' AS Col31 FOR XML RAW, ELEMENTS)
set @xml2 = (SELECT 2 AS Col12, ' ' AS Col22, 'ABC' AS Col32 FOR XML RAW, ELEMENTS)
DECLARE @xml xml;
SET @xml = Cast('<ROOT>' + ISNULL(@xml1, '') + ISNULL(@xml2, '') + '</ROOT>' as xml)
SET @xml.modify('delete //*[not(node())]');
-- Some Way to Remove the XML Tags with Empty space here.
select @xml as XMLString
/* Output of the Above script.
<ROOT>
<row>
<Col11>1</Col11>
<Col21> </Col21> -- This XML Tag with a white space should be removed
<Col31>ABC</Col31>
</row>
<row>
<Col12>2</Col12>
<Col22> </Col22> -- This XML Tag with a white space should be removed
<Col32>ABC</Col32>
</row>
</ROOT>
Welcome to MSDN Forums.
Feel free to ask your questions and Please Note to Vote all helpful topics and
Mark all answering posts.
You Value Community's efforts and Community values your faith.
- Arun Kumar Allu

It would have helped if there had been a trim() function in XQuery.
With some trial and error and inventive thinking I came up with this:
<span style="color:Blue">SET</span> @xml.modify(<span style="color:#A31515">'delete //*[. <= " "]'</span>);
As they say: it seems to work. But I leave no warranties.
Erland Sommarskog, SQL Server MVP, [email protected]
Wow Erland  this
seems to work, I need to test it against my data and update on this. Thanks again.
Welcome to MSDN Forums.
Feel free to ask your questions and Please Note to Vote all helpful topics and
Mark all answering posts.
You Value Community's efforts and Community values your faith.
- Arun Kumar Allu

Similar Messages

  • Accssing xml tags with name space

    <XML>
    <A> Text line 1 </A>
    <A> Text line 2 </A>
    <A> Text line 2 </A>
    </XML>
    I need to know how to Create and access the tag values using name space. could you send me the code please ?
    Thanks

    Hi:
    If you want to use namespace in XML file. You have to define a DTD file or Schema file. Those file you created to validate the XML file. So you can also define a namespace in DTD and Schema or not.
    When you define a namespace in DTD or Schema, you can use a prefix in front of tag name.

  • Remove XML tags from XML element in Oracle

    Hi,
    I have a requirement where I have to remove all the xml tags from xml element with banks, currently I'm using replace 4 times to replace all different types of xml tags, performance is really bad. is there any better option to remove xml tags from xml data leaving the actual data. please find the example data below.
    select
    TO_CLOB(REPLACE(REPLACE(REPLACE(REPLACE
    ('<Concatcolumn><ConcatGroupID>MyText Data goes here </ConcatGroupID><ConcatGroupID>Data agian</ConcatGroupID></Concatcolumn>','<ConcatGroupID>'),'<Concatcolumn>'),'</ConcatGroupID>',';'),';</Concatcolumn>')) AS Concatcolumn
    from dual
    **************Out put*************
    MyText Data goes here ;Data agian

    One way is to use xquery:
    SQL> with t as
    select xmltype('<Concatcolumn>
                          <ConcatGroupID>MyText Data goes here </ConcatGroupID><ConcatGroupID>Data agian</ConcatGroupID></Concatcolumn>'
       ) xml from dual
    select xmlquery('string-join(//text(), ";")' passing xml returning content).getclobval() xml from t
    XML                                                              
    MyText Data goes here ;Data agian                                
    1 row selected.

  • Firefox 3 cannot download files with white space in the filename

    When opening attachments in e-mail Firefox is unable to handle files with white space in the name. This is not the same as the white space file name truncation problem documented on this site (where file names with white space are truncated on saving.) The issue is that the browser will prompt to allow the file to be saved, but it will not prompt to open the file as an option. If I rename the file to remove white space then I do receive the "Open with..." dialog box. I verified that Firefox 2 did not have this problem and I can open attachments with white space in the file names just fine using that version of the browser (2.0.0.20).
    == This happened ==
    Every time Firefox opened
    == Upgraded to version 3

    When a user clicks on an attachment with spaces, the filename is truncated to the first whitespace. While IE, Chrome & Safari handle this, Firefox refuses to accept mime headers with unquoted filename parameters. According to Firefox's bugzilla/knowledgebase, Firefox's behavior is the correct behavior and it's a problem with most webservers or web applications. This problem can be easily corrected by surrounding the filename parameter with double quotes.
    Eg.
    Response.AddHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");

  • Org.xml.sax.SAXParseException: White spaces are required between publicId

    Hi,
    Im migrating an application from weblogic to tomcat 5.5.23 with java 1.5. application involved PDF generation using xalan.jar for transformation. tht pdf generation part is not working in tomcat. Im getting a "org.xml.sax.SAXParseException: White spaces are required between public-Id and system id" error.
    so i replaced the old xalan.jar with latest one ( xalan 2.7.1 ) still no use. I have also explicitly defined the property "javax.xml.transform.TransformerFactory" to "org.apache.xalan.processor.TransformerFactoryImpl" still getting the same exception.
    plz help
    Thanks in Advance.

    I have had good results using JTidy to parse HTML into a DOM.

  • Query return/wddx with white space

    i have a query return i am looking at which i will send it to
    another program but for some reason this is coming with some white
    space. i have following questions.
    if i make changes on the admin console for white space
    management do i need to reboot.
    i am trying to use cfsetting but it is still producing some
    white spaces at the beginging. when i see the source.

    The CF admin setting helps but does not completely solve
    whitespace issues. (Look at the source for these forum pages, for
    example..)
    Also, beware of people who tell you to strip the whitespace
    off after the fact by manipulating CF output as though it were a
    string.
    Put this at the top of your Application.cfm or
    Application.cfc:
    <CFSETTING EnableCFOutputOnly = "yes">
    This means that nothing makes it to the page unless it is
    inside <CFOUTPUT> tags or in WriteOutput ().
    This is good practice anyway because it encourages you to
    separate output code from logic and makes you more conscious of
    whitespace as you code.
    Finally, for XML to some programs or the <DOCTTYPE>
    declaration to IE know that the output must be immediately after
    the first <CFOUTPUT> with no whitespace of any type.
    IE:
    <CFOUTPUT><?xml version="1.0" encoding="UTF-8"?>
    works but
    <CFOUTPUT>
    <?xml version="1.0" encoding="UTF-8"?>
    doesn't.

  • JDK 1.6 Installation INSTALLDIR with white space

    Hi,
    I am trying to install jdk 1.6 in silent mode. I am using following command:
    <jdk1.6>.exe /s INSTALLDIR="C:\Program Files\CA\IAM\JDK1.6"
    But this shows me the usage dialog. When I remove INSTALLDIR then it gets installed in Program Files\Java. When I use a INSTALLDIR path that does not contain any white space then also it gets installed successfully. What could be the problem with the white space in "Program Files"?
    Thanks,
    Rajeev

    Ah, I found it. For anyone interested the answer can be found in a bug report addressing this very issue:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4966488

  • Replacing Selected Areas with White Space

    I am using Acrobat version 8 on an XP Pro SP2 system.
    I have a PDF file. Certain selected areas I wish to replace with pure white space. How can I do that?

    You will find other ways which SEEM to remove blank material but avoid
    them like the plague since it is very easy to get back the hidden
    material. Redaction needs specialist tools. There is a plug-in, Redax
    from http://www.appligent.com/
    Aandi Inston

  • Facing problem while removing XML tags which has been generated from SAP

    Hi All,
    I am facing problem in MII, while i trying to remove 1st 2 XML tags of XML as generated from SAP.
    Here is XML which has been generated from SAP
    u201C<?xml version="1.0"; encoding="UTF-8"?>
    <ZCIFSCHEDULE>
    <SCHEDULE>
    <MESSAGE_TYPE/>
    <SITE>A300</SITE>
    <SHOP_ORDER>2012020856</SHOP_ORDER>
    <QTY_TO_BUILD>6.000<;/QTY_TO_BUILD>
    <DATE_TIME>08-FEB-2012 20:57:21 +05:30</DATE_TIME>
    <OPERATION>PRS</OPERATION>
    <ITEM>IN-CT00228</ITEM>
    <DPICS_CODE>1229</DPICS_CODE>
    <REVISION/>
    <CYC_TIME_CURING/>
    <FLAG_AGING/>
    <AGING_MIN/>
    <PRODUCTION_VERSION/>
    <CYC_TIME_OC/>
    <CYC_TIME/>
    </SCHEDULE>
    </ZCIFSCHEDULE>u201D
    From above i want to remove 1st 2 tags and last one tag i.e.  u201C<?xml version="1.0"; encoding="UTF-8"?> , <ZCIFSCHEDULE> and last tag ZCIFSCHEDULE>u201D
    Its urgent!
    Did anyone done regarding this issues. Thanks in advance.
    Kind Regards,
    Praveen Reddy

    Hi Praveen,
    Are you trying to make the xml into a string?  I think if you remove the first tag, it will either automagically reappear or it will throw and error as being poorly formed xml. 
    In general, you can remove the nodes by the use of indexes.  Since you are operating at the root level, I am not sure how well it will work, but if your xml is in a property, you can reference the specific nodes by something like this:  myXML.Output{/*[1]} which if you put it in a tracer will display the contents of the first node (or blank if there are child nodes).  The node index can be dynamically set, but start with the simple hard coded one.  I would also start at the lowest child level to verify that it is working properly (a tracer will display the contents specified by the index).  You can also google xml indices (or indexes) and it will point to some other useful xml operators.
    I suggest that you play around with it and also work with the Link Types (hint: removeXML).
    Regards,
    Mike

  • Multiple Return to Single Return is Removing XML Tag

    Dear All,
    I'm Using  -  InDesignCS3 + WinXP + VB6.
    I've a InDesign file which is created by XML Import (Our Customers needs XML Output also at the End).
    After importing i've done few modifications (Moved Figs & Captions to frames by PlaceXML method).
    At this stage an Extra Paragraph Return (where the Figure placed while import, before moving to frame) is available.
    When i tried to remove this by replace, XML Tag for the Figures are also deleted from the XML Structure of the Document.
    Is there any other way to do this? - Please Suggest
    Thanks in Advance,
    SaRaVaNaN.N...

    Hai,
    Here is a Simple Example for my Question.
    Ex: Import the following XML and from the XML Structure (Ctrl+Alt+1) Move <figure> to a new Frame.
          You'll see an extra paragraph return between those two paragraphs.
              <root><para>...text 1...</para>
              <figure><title>fig.1</title><img href="myFig1.jpg"/><caption>about the figure</caption></figure>
              <para>...text 2...</para></root>
    GoTo Story Editor (Ctrl+Y). You'll see as follows:
              [x]para>...text 1...<para[x]
              [x]figure]
              [x]para>...text 2...<para[x]
    After Replacing '^b^b' to '^b' it looks like below:
              [x]para>...text 1...<para[x]
              [x]para>...text 2...<para[x]
    Figure Tag is removed from the XML Structure and Story Editor. Is there any way to remove this extra pragraph reture with keeping the XML Structure?
    Thanks...

  • Mapping of XML tags with column

    My xml structure is :
    <PARAMS>
    <ROWSET>
    <ROW NUM="1">
    <SID>man123</SID>
    <PO>
    <PO>OBJ1</PO>
    <PI>
    <PI>PARENTOBJ1 INSTANCE</PI>
    </PI>
    </PO>
    </ROW>
    </params>
    My table structure is :
    CREATE TABLE TEMP(SID VARCHAR2(20),PO POBJECT_T)
    where Object types are:
    CREATE OR REPLACE TYPE PINSTANCE_T AS OBJECT (PI VARCHAR2(255),CO COBJECT_T);
    CREATE OR REPLACE TYPE POBJECT_T AS OBJECT (PO VARCHAR2(255),PI PINSTANCE_T);
    To store this XML directly into table i have to have Column with name "PO" (same as XML tag).I am using this same table to store other XML with same tags . With this limitation its difficult to do so.Is there any way to map XML tag to column with different name????
    Thanks

    Hi,
    thx for your Reply,
    seems to work basicly but i get now in the IDE warnings with:
    "Data binding will not be able to detect changes when using
    square bracket operator. For Array, please use
    ArrayCollection.getItemAt() instead. "
    And how can i access the next item something like this didnt
    work right
    try someniceid.lastResult["some-root"]["someother-root"]
    I had to use single quotes (') to get it to work.
    Any ideas?
    Kind regards,
    Marko

  • Remove XML tags in the File Adapter

    Hi,
    I have a JDBC to File interface. However, there is a requirement to remove some of the XML tags from XML produced by the File Adapter.
    For example,
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_XML xmlns:ns0="namespace">
       <XMLIntegration>
             <Prices COLUMNS="Index, Date, Price">
             <Index>Fuel</Index>
             <Date>2007-05-01 00:00:00.0</Date>
             <Price>0</Price>
            </Prices>
          <Prices COLUMNS="Index, Date, Price"/>
      </XMLIntegration>
    </ns0:MT_XML>
    needs to be changed to
       <XMLIntegration>
             <Prices COLUMNS="Index, Date, Price">
             Fuel, 2007-05-01 00:00:00.0, 120.65
            </Prices>
      </XMLIntegration>
    Does anyone know how to do this? I'm using the File Content Conversion Message Protocol but I'm not having much success

    hi,
    you just need to have this:
    <XMLIntegration>
             <Prices COLUMNS="Index, Date, Price">
             Fuel, 2007-05-01 00:00:00.0, 120.65
            </Prices>
      </XMLIntegration>
    as your target message in your mapping
    and map all values to Prices tag
    you don't need no content conversion - just the mapping
    Regards,
    michal

  • Embedding inline HTML data in XML using the mx:XML tag with &lt; and &gt;

    What is best practice for embedding HTML within the
    <mx:XML> tag? Programmatically, I can implement this
    successfully:
    [Bindable]
    public var xmlDP:XML = <component data="&lt;" />;
    However, I get the following error if I try to store the same
    data inline in an mx:XML tag, as such:
    <mx:XML id="xmlDP">
    <component data="&lt;" />
    </mx:XML>
    Error #1095: XML parser failure: Unterminated attribute.
    If I change the MXML tag as follows, it works fine:
    <mx:XML id="xmlDP">
    <component data="&amp;lt;" />
    </mx:XML>
    Unfortunately, I also can not source the mx:XML tag to an XML
    file which uses &lt; or &gt; codes, as it yields the same
    results. This leads me to believe that the <mx:XML> tag does
    not support the special character codes for < and >, but why?
    Incidentally, this code also gives a 1095 error:
    <mx:XML id="xmlDP">
    <component data="&#0060;" />
    </mx:XML>
    This is causing an issue with my source data as it is not
    hand typed into Flex, and standard XML supports the &lt; and
    &gt; codes. I have tried a full HTML string, as shown below,
    but this also generates the error:
    <mx:XML id="xmlDP">
    <component data="&lt;b&gt;Test&lt;/b&gt;"
    />
    </mx:XML>
    Many thanks for any input you may have!

    I’m generating the XML source file with
    Microsoft’s XML Notepad 2007. It will encode invalid special
    characters automatically. My understanding is that this is the
    proper way to handle the less than symbol in a XML string, that is
    to say using the &lt; code.
    With respect to the escape and un-escape methods, I am able
    to successfully implement these in AS, but not in MXML. This makes
    sense considering they are AS methods, but I was hoping to be able
    to do something like:
    <mx:XML id="xmlDP">
    <component data="escape('<');" />
    </mx:XML>
    This gives the following compilation error:
    The value of attribute "data" must not contain the '<'
    character.
    As does using the escape character as such:
    <mx:XML id="xmlDP">
    <component data="\<" />
    </mx:XML>
    Below is an example of what the escape character may be used
    for in AS:
    var myString:String = "\"";
    trace(myString);
    // result: "
    Likewise, I can escape the < character as such:
    var myString:String = escape("<");
    trace(myString);
    // result: %3C
    <mx:XML id="xmlDP">
    <component data="%3C" />
    </mx:XML>
    trace(un-escape(xmlDP.@data));
    // result: <
    As you can see, using %3C and unescaping in AS will yield the
    correct result; however, this is not a practical method of
    representing the data in MXML as I would have to write an AS method
    to un-escape the XML string anyway, so I might as well just store
    the data in AS to begin with. I was hoping for a way to source an
    mx:XML object, without having to load it into ActionScript
    manually. Here’s an example of the functionality I would
    expect:
    <mx:XML id="xmlDP">
    <component data="&gt;" />
    </mx:XML>
    trace(xmlDP.@data);
    // result: >
    Only this does not work for the less than symbol. I’m
    assuming at this point that this is a bug in the Flex compiler.
    Thanks again for your help troubleshooting this one!

  • Problem with white space

    Hi,
    I do an insert in a table. I try to insert a white space in a varchar2(1) field. I use parameter query.
    But when i try to do this, odp.net insert a NULL value instead of the white space.
    Is there a parameter to change to avoid this problem ??
    Thanks in advance.

    Not sure if this is exactly the issue but
    you could try the current Patch 4147997
    ODP.NET Patchset 9.2.0.4.15
    or try a Workaround of binding parameters as Char which does not remove trailing spaces:
    cmd.Parameters.Add(new OracleParameter("data",
    OracleDbType.Char,10)).Value=" ";
    or
    cmd.Parameters.Add("data",
    OracleDbType.Char,10," ",
    System.Data.ParameterDirection.Input);

  • Problema with white space at the bottom

    http://formypets.net/cat_training.html
    I keep getting that strange white space at the bottom and I
    have no idea what to do. Can someone give me a hand, please?

    labecs wrote:
    > I was just hoping to get a recommendation about where I
    can go to have someone
    > check my code and fix it where it needs fixing. I
    haven't been able to get an
    > opinion about the site, which is my first and I am just
    learning, and i don't
    > know if there 's something I'm doing really wrong or
    right or whatever. Anybody?
    >
    Hi,
    Try a new post asking for a site check or a site critique -
    you'll no
    doubt get differing advice about best practises on the
    construction -
    take what you get objectively, most will be constructive,
    don't be
    disheartened and don;t forget it's your client who is the
    person you
    most have to please.
    I think it looks great and for a first site - quite
    incredible really -
    you seem to have a fairly good grasp on what's going on with
    the code
    and (you may get crit for using absolute positioning) you
    also seem to
    have a grasp on relative and absolute positioning.
    One wee thing I see (sorry don't have time to trouble shoot
    for you) is
    a slight layout difference between IE and FF - possibly a
    double margin
    bug - a bigger gap between the centre and the right columns!
    Oh - and you might want to consolidate your css - shift the
    embedded
    styles to your linked sheet.
    HTH
    chin chin
    Sinclair

Maybe you are looking for

  • Difference G/L amount in FBL3N and F.01 (B/S STATEMENT)

    Hello to everyone, I got a IV document with material on the last date of previous year, (But entry date is this year.) Whem post to FI, there are two accounting document post to FI. From the TABLE BKPF, one is previous year and another is this year.

  • Quicktime 7 crashes

    Hello. I recently upgrade my intel iMac to Lion- 10.7.5. Now whenever I try to open quicktimes in QT 7 pro, it immediatly crashes. However, they do play in QT X. Any suggestions? thanks

  • I have a rectangle on my screen that  i can't get rid of it. any help?

    I have a rectangle on my screen that  i can't get rid of it. any help?

  • New MacbookPro w/Mountain Lion. Can't see external HD

    I just bought a new MacBookPro and it cam with Mountain Lion. I have an external HD and was working fine, then I ejected it, pluged it back into my iMac with Lion, and it can't be found. I tried on my new MBPro, and same thing... can't be found. Open

  • Where-Used List for Assemblies

    Hi PM Experts, Can you tell me hw to see the Where-Used List for assemblies.I m using CS15 T-Code for the same,but the problem is that i can see only for one assembly not for multiple assemblies.what is t-code for multiple. Regards, Raju chauhan