How to remove extra spaces in a xml formatted string

Hi,
I am trying to remove extra spaces between the xml tags. For
example, if a string is something like
' <header 1> <header 2> test </header 2> </header1>'
I want to get rid of the spaces only between the closing tag of header 1 and opening tag of header 2 and closing tag of header 2 and opening tag of header 1, in short ,I want to remove the extra spaces between the tags if there are no other characters between them. I do not want the remove the spaces between closing tag header 2 and opening tag of header ,as there is occurence of other characters.
I am aware that this can be done by looping through the string and using instr to identify the characters '<' and '>', but I would like to use it as a last resort only.
Can anyone suggest me a better way of doing it in a single go by manipulating the data?
Any help is really appreciated.
Regards,
Anil.

You can use the replace function. If you only expect one extra space, then:
scott@ORA92> select replace ('<header 1> <header 2> test </header 2> </header1>',
2      '><', '><')
3 from dual
4 /
REPLACE('<HEADER1><HEADER2>TEST</HEADER2></HEADER
<header 1> <header 2> test </header 2> </header1>
If you expect more extra spaces, then you will need to wrap another replace function around it for each space, for example the following will eliminate up to three spaces:
scott@ORA92> select replace (replace (replace ('<header 1> <header 2> test </header 2> </header1>',
2      '>     <', '><'), '>     <', '><'), '> <', '><')
3 from dual
4 /
REPLACE(REPLACE(REPLACE('<HEADER1><HEADER2>TEST
<header 1><header 2> test </header 2></header1>

Similar Messages

  • How to remove extra spaces from Data Matrix Label?

    Hi All,
    Kindly let me know how we can remove extra spaces from Data Matrix Label.
    Suppose we have this following code in SO10.
    ^FO1380,1879^COY,78^BY4^BXR,6,200^FH^FD[)>_1E06_1DF01001T_1D6JUN&v_huf&&v_hul&_1DV&v_supnum1&_1D16K&v_del&_1D6D&v_flddat1&095_1D2L&v_unload&_1D
    P&v_article&_1D4L&v_madein&_1D_1E_04^FS.
    Variable have there own value. and the desired result will be shown like the attachment.
    But in my code it splits into new line when CMIR value has 3 spaces.
    If CMIR value is 1S0 820 355 A . then it creats a new line.
    Kindly suggest me any possible solution.
    Thanks,
    Partha

    Hi Gaurav,
    In print preview we can't see any space or new line. But when it scanned by TSB (barcode scanner) it will generate a new line when there is 3 space CMIR value.
    So where should I write SHIFT CMIR LEFT DELETING LEADING space this code?
    Because there is no space coming at the time of debugging or print preview.
    And in SO10 the code written as
    ^FO1380,1879^BY4^BXR,6,200^FH^FD[)>
    Here CMIR value is 1SO 820 303 A
    and generated output is like this.
    And desired output should be like this.

  • Given some xml and an xsd, how to remove extra stuff in the xml.

    Hi. I have a question. I am trying to use the various XML libraries to parse/validate an xml file given an XSD schema. I want to remove the extra stuff in the xml to output a new xml. The problem is as I validate or parse the SAXParseException it produce only gives me the localName. Is there a way I can keep track of something detail like the XPath as I validate or parse??? Thank for the help in advanced

    forgot to mention. Basically, I want to try to validate and find all the errors in the an old xml, then be able to fix the errors to end up having an valid xml file.

  • Remove extra space

    Hi master,
    how to remove extra space from the tables and columns
    thanks

    Apparently table and/or column names that have been created don't match those being used in queries.
    This typically happens when you use tools that generate scripts with object (table/column) names in "double-quotes" thus causing them to be CaSe-SeNsItIvE to Oracle.
    See this short demo of sensitive object names :
    SQL> create table "My Table"  (col_1 varchar2(5));  -- Sensitive Name used
    Table created.
    SQL> desc my table 
    Usage: DESCRIBE [schema.]object[@db_link]  -- cannot find an object by the name "my table"
    SQL> desc "My Table"  -- I must explicitly use the Sensitive Name now !!!!
    Name                                                                     Null?    Type
    COL_1                                                                             VARCHAR2(5)
    SQL> desc "MY TABLE"  -- The name does not map across CASE either !
    ERROR:
    ORA-04043: object "MY TABLE" does not exist
    SQL> create table MY TABLE (col_1 varchar2(15));  -- Normally, object names cannot contain spaces !
    create table MY TABLE (col_1 varchar2(15))
    ERROR at line 1:
    ORA-00922: missing or invalid option
    SQL> create table MY_TABLE (col_1 varchar2(15));  --- this is the correct way to name an object.  DON'T USE "double-quotes" ; DON'T USE SPACEs
    Table created.
    SQL> desc MY_TABLE  -- the properly named
    Name                                                                     Null?    Type
    COL_1                                                                             VARCHAR2(15)
    SQL> desc "My Table"  -- the first , Sensitive name
    Name                                                                     Null?    Type
    COL_1                                                                             VARCHAR2(5)
    SQL>Hemant K Chitale
    http://hemantoracledba.blogspot.com

  • Remove extra space value of the field  in text element

    Dear All,
    Can any one please help me out to remove the blank spaces in the text elements of SF.
    we are printing Label in which i want print  quantity of material. and i am using MSEG-MENGE for quantity of maetrial.
    But the issues is when we are printing the label. We are getting spaces  in the Text elements fields &MSEG-MENGE&.
    i am also check menge field within mseg table. in which menge field define as QUAN data type with length 13.
    <
    MAT CODE:&t_MSEG-MATNR&
    DESC:&MAKTX&
    QTY:&t_MSEG-MENGE&          
    UOM:&t_MSEG-MEINS&
    >
    My Output in SF:
    MAT CODE:11000002
    DESC:Coarse Aggregate 10mm Sieve
    QTY:             960
    UOM:LBM
    MIGO.NO.:4900000025
    how to remove extra blank spaces in the text elements ( QTY:             960 )
    guide me.........

    Dear All,
    I am using  code block in SF before text element.
    In  The Text Element ...
    <
    MAT CODE:&t_MSEG-MATNR&
    DESC:&MAKTX&
    QTY:&t_MSEG-MENGE&
    UOM:&t_MSEG-MEINS&
    MIGO.NO.:&t_MSEG-MBLNR&
    PO.NO.:&t_MSEG-EBELN&
    LOCATION:&t_MSEG-WERK&&NAME1&
    >
    In programe Line ( code block )....
    <
    read table t_mseg index w_index.
    qty = t_mseg-menge.
    condense qty.
    SELECT SINGLE name1 FROM t001w INTO name1 WHERE werks = t_mseg-werks.
    SELECT SINGLE maktx FROM makt INTO maktx WHERE matnr = t_mseg-matnr.
    >
    My Output:
    MAT CODE:11000002
    DESC:Coarse Aggregate 10mm Sieve
    QTY:                                                      960
    UOM:LBM
    MIGO.NO.:4900000025
    Only problem in value of Quantity field .
    guide me.........

  • IDCS5-JS:Remove extra space in equation

    How to remove around space [extra space] in equations eps file generated from Mathtype when placing it in InDesign.
    Any suggestions....

    Hello
    The simplest way is...
    Open Windows registry, find key
    HKEY_CURRENT_USER\Software\Design Science\DSMT6\Windows
    Now you can change
    PicturePadding
    The default is 2 (possible points, but I don't sure), but you can change it (0 - to delete all paddings).
    BUTdon't forget to process all your equations (after PicturePadding was changed) in Word (by Format) or in InDesign (by Batch convertion... - it's possible if you use MT-Script for InDesign (www.mtscript.ru))
    And only after that you will see equations without paddings.
    Thank you.

  • How to remove extract space between pages in smartform without changing output

    Hello Experts,
    I've been given a requirement where I need to remove extra space between pages of a smartform (refer to the attachment). If you look at the following screen shot then you will notice that that there is a command provided to display details on these pages which has a checkbox 'Go to New Page'.
    When I removed the above New Page comment then still I don't see the expected output (Refer to the attached screen shot 'Expected' to see what I need).
    Also there is another there is another New Page command (as shown below).
    When I tried to removed the above New Page Command then output was totally changed which user don't want (as shown below. Table should have been break on BCVI on red line, which happens today but with so much extra space).
    To view the correct output how user want please have a look at 'Expected' screen shot.
    Now the question is what change I should make in my smartform to accomplish the expected output.
    Many thanks in advance.

    Hello,
    I think that it should work, this construction of an loop node including all relevant items and at the event TAB event sort field only these items are copied in the OUTPUT_TAB which should be printed in a separate table on the form. After having printed the table, the content of the internal table is cleared.
    I suppose that you first should check if this TAB "event sort field" includes the correct criteria for the necessary group change. If this event is really defined correctly, then I only have one hint for you.
    I know that the only possibility to define a page break in a table in the Window MAIN is to use the following technique:
    Define an outside loop node and in this loop node a table node, but this table does not have a internal table to be looped through. It includes only the fields to be printed, maybe you have to re-design your table node.
    By the way only then you can define a command node including a page break during the processing of an internal table.
    Regards
    Juergen

  • Removing extra spaces from a long document

    Hello
    I have seen a number of find/change and GREP formulas to do similar things. I have NO scripting or coding experience and have labored to understand GREP.
    So I am a little afraid to use it as I don't know what all the modifiers refer to (I do have a printout of some neat GREP cheatsheets like Mike Witherell's that I can absorb until I obtain a good reference )
    I need something I can copy and paste into either find/change or GREP dialog that will do the following in less than 12 steps (hopefully) without doing something catastrophic like removing all of my paragraph marks (which I almost did using someones GREP expression)
    No spaces before any comma, period, exclamation mark, question mark, colon, semicolon
    One space only after any of those
    One Space before any opening parenthesis and one space after the closing parenthesis
    No space after the opening parenthesis or before the closing parenthesis
    Remove any double or extra spaces ( en, em etc.)
    Remove any commas before parentheses
    Remove any spaces after a paragraph mark
    I think that's it
    I did find this one recently (Maybe Jongware?)
    [~m~>~f~|~S~s<~/~,~3~4%]{2
    Which from my dim understanding addresses em, en, flush and hair space ,  nonbreaking space ,figure space,third space--not sure of the rest. Really this is way over my head.
    I know this will be a piece of cake for you guys
    Thanks

A: Removing extra spaces from a long document

Peter is too modest, he's doing just great.
No space BEFORE-One Space after ---period,semicolon,colon, exclamation, question mark,CLOSING Parenth,Bracket,Brace, single & Dbl. quotation marks
Find (\s)([.,;:!\)\]\}~}~]])
Replace with $2
No space AFTER-One Space Before----OPENING bracket,brace,parenthesis,Dbl & single quotes
Find ([\[\{\(~{~[])(\s)
Replace with $1
These remove the space before/after but do not automatically add a space after/before.
In the first case, you could add a space right after the '$2' in the Replace With string, but it already may have a space, in which case you suddenly have two. One alternative is to optionally remove it with the Find string (add it as an optional match) and always add it with the Replace string, but remember that this string will only be found if there is a space preceding it. That way you'd only check the space after in cases where there was a bad space before.
So I propose you add another two find/changes to add the space, only when necessary.
One Space After: find
([.,;:!\)\]\}~}~]])(?!\s)
replace:
$0 [followed by one single space]
One Space Before: find
(?<!\s)([\[\{\(~{~[])
replace:
[one single space] $0
Color-coding with my WhatTheGrep might make it just a tad clearer what's going on in that jumble of codes:
(1 [ .,;:! \) \] \} ~} ~] ] 1) (?!! \s !)
and
(?<!<! \s <!) (1 [ \[ \{ \( ~{ ~[ ] 1)
(Orange is lookahead/lookbehind, blue is a regular escaped character, pink is an InDesign special character, green is normal grouping parentheses, and lavender is a character group.)

Peter is too modest, he's doing just great.
No space BEFORE-One Space after ---period,semicolon,colon, exclamation, question mark,CLOSING Parenth,Bracket,Brace, single & Dbl. quotation marks
Find (\s)([.,;:!\)\]\}~}~]])
Replace with $2
No space AFTER-One Space Before----OPENING bracket,brace,parenthesis,Dbl & single quotes
Find ([\[\{\(~{~[])(\s)
Replace with $1
These remove the space before/after but do not automatically add a space after/before.
In the first case, you could add a space right after the '$2' in the Replace With string, but it already may have a space, in which case you suddenly have two. One alternative is to optionally remove it with the Find string (add it as an optional match) and always add it with the Replace string, but remember that this string will only be found if there is a space preceding it. That way you'd only check the space after in cases where there was a bad space before.
So I propose you add another two find/changes to add the space, only when necessary.
One Space After: find
([.,;:!\)\]\}~}~]])(?!\s)
replace:
$0 [followed by one single space]
One Space Before: find
(?<!\s)([\[\{\(~{~[])
replace:
[one single space] $0
Color-coding with my WhatTheGrep might make it just a tad clearer what's going on in that jumble of codes:
(1 [ .,;:! \) \] \} ~} ~] ] 1) (?!! \s !)
and
(?<!<! \s <!) (1 [ \[ \{ \( ~{ ~[ ] 1)
(Orange is lookahead/lookbehind, blue is a regular escaped character, pink is an InDesign special character, green is normal grouping parentheses, and lavender is a character group.)

  • Removing extra spaces from email attachment of text file

    Hi All,
    I am having a question in opening email attachment file in text mode.
    Whenever I am trying to open a CSV file in text mode after each row it adds blank spaces. These blank spaces are to complete the 255 characters on each row I guess.
    My client doesn't want these space. So can anybody tell how to remove those spaces?
    <removed by moderator> response would be helpful.
    Thanks and Regards
    Nishad
    Edited by: Thomas Zloch on Apr 28, 2011 4:02 PM - priority normalized

    Hi,
    There is no solution for this as u know that the data which you r sending in csv its actually getting populated from an internal table.
    You cannot make your internel table dynamic for this requirment.
    It should have a fixed length. Now if the data is less then also the length.
    So u have identified correct that because of 255 the blank space is population, nothing is in your hand.
    U have to convince the client, to make them understand where is the limitation.
    Thanks & Regards
    Prasenjit

  • How to remove white space between two answer reports

    How to remove white space between two answer reports
    In Dashboard section I have 2 rqeuest. Each request renders Table View. When I display dashboard, it show white space separating the 2 table views. How do I get rid of the white space/white band ?

    See this link
    Re: Eliminating the space between two reports in OBIEE dashboard page Section
    Regards,
    Sandeep

  • Why can I not remove extra spaces from Mail when composing?

    I am using Mail Version 8.1 and I cannot find a way to remove extra spaces from between my lines while composing. Every Enter makes the cursor go down two lines and there is no way to type in the space in between. There seems to be now way to see the html or any tags that can be causing this, and I cannot seem to find any setting to change the line spacing either. Does anyone know where to find any of these options so I can simply make the text single space?

    Open a message-editing window. Under the Edit menu, deselect all the options in the Spelling and Substitutions sub-menus. Test.

  • How to remove ghost space on Camera Roll under Usage. No photos on camera. 545MB shown on Camera Roll and 1.8MB on Photo Stream

    How to remove ghost space on Camera Roll under Usage. No photos on camera. 545MB shown on Camera Roll and 1.8MB on Photo Stream?
    Trying to clean up space to download updated iOS. Thanks!
    Have tried unsuccessfully the left swipe and pressing the red delete. No change.

    The only problem is I have only 1.6GB available and need 3.7 to update to the iOS7.  I also have 2.6GB in the "Other" catagory.  How do I access the "Others" area in iTunes in order to see what is there and what I might be able to delete in order to create the amount of space needed.  Thanks for your help!

  • How to write the oracle data as XML format. (.XML file)

    create or replace procedure pro(p_number )
    is
    cursor c1 is select *from emp where empno=p_number;
    v_file utl_file.file_type;
    begin
    v_file := utl_file.fopen('dirc','filename.txt','w');
    for i in c1 loop
    utl_file.put_line(v_file,i.ename || i.empno ||i.job);
    end loop;
    closef(v_file);
    end;
    Now my client want instead of .txt file he need .xml files
    File should contains xml tags. can any one help regarding this.. with one example.
    How to write the oracle data as XML format. (.XML file)

    hi,
    hope this example will do something....
    SQL> select employee_id, first_name, last_name, phone_number
    2 from employees where rownum < 6
    EMPLOYEE_ID FIRST_NAME LAST_NAME PHONE_NUMBER
    100 Steven King 515.123.4567
    101 Neena Kochhar 515.123.4568
    102 Lex De Haan 515.123.4569
    103 Alexander Hunold 590.423.4567
    104 Bruce Ernst 590.423.4568
    SQL> select dbms_xmlgen.getxml('select employee_id, first_name,
    2 last_name, phone_number from employees where rownum < 6') xml
    3 from dual;
    *<?xml version="1.0"?>*
    *<ROWSET>*
    *<ROW>*
    *<EMPLOYEE_ID>100</EMPLOYEE_ID>*
    *<FIRST_NAME>Steven</FIRST_NAME>*
    *<LAST_NAME>King</LAST_NAME>*
    *<PHONE_NUMBER>515.123.4567</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>101</EMPLOYEE_ID>*
    *<FIRST_NAME>Neena</FIRST_NAME>*
    *<LAST_NAME>Kochhar</LAST_NAME>*
    *<PHONE_NUMBER>515.123.4568</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>102</EMPLOYEE_ID>*
    *<FIRST_NAME>Lex</FIRST_NAME>*
    *<LAST_NAME>De Haan</LAST_NAME>*
    *<PHONE_NUMBER>515.123.4569</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>103</EMPLOYEE_ID>*
    *<FIRST_NAME>Alexander</FIRST_NAME>*
    *<LAST_NAME>Hunold</LAST_NAME>*
    *<PHONE_NUMBER>590.423.4567</PHONE_NUMBER>*
    *</ROW>*
    *<ROW>*
    *<EMPLOYEE_ID>104</EMPLOYEE_ID>*
    *<FIRST_NAME>Bruce</FIRST_NAME>*
    *<LAST_NAME>Ernst</LAST_NAME>*
    *<PHONE_NUMBER>590.423.4568</PHONE_NUMBER>*
    *</ROW>*
    *</ROWSET>*
    ask if you want more assistance.
    thanks.

  • How to see the IDOC structure in XML format

    Hi, I am ver new to MII. I configured connection between SAPand SAP MII and IDOC is triggering in SAP MII. I can see the idoc triggered in Message monitor.
    Now my query is how to see the IDOC structure in XML format? I written a transaction where I am assigning transaction.xml to my Local.xml and trying to display with message action block. When I display the message I am getting message as below
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    There is no data in the xml, but in SAP side i seen data and segment which sent to MII as a IDOC. Please help me how to resolve this issue.

    Hi, Thanks for quick response.
    In Message monitor I seen the IDOC list after executing POIT transaction code in SAP.
    But the display button is disabled always in message monitor screen. I want to take this IDOC and save it in my SQL database. So I want to see this IDOC structure in XML format. Where i can see this structure?

  • Parse XML formatted String

    Hi All,
       I have a string field that is formatted in XML format. What I want to be able to do is pull a specific element from the xml formatted string.
    Example string:
    <customer><name>john</name><id>25636</id></customer>
    I want to retreive just the id number of 25636 from this string.
    I would I go about accomplishing this?
    Thank you in advance,

    I fixed it on my own.
    Here' s my answer for others that may need it:
    if(instr({field.xmlstring},'</id>')  - instr({field.xmlstring},'<id>') = 7)then
       mid(totext({field.xmlstring}),instr({field.xmlstring},'<id>')+4,3)
    else if(instr({field.xmlstring},'</id>')  - instr({field.xmlstring},'<id>') = 8)then
       mid(totext({field.xmlstring}),instr({field.xmlstring},'<id>')+4,4)
    else if(instr({field.xmlstring},'</id>')  - instr({field.xmlstring},'<id>') = 9)then
       mid(totext({field.xmlstring}),instr({field.xmlstring},'<id>')+4,5)
    I use the conditions to cover all possible lengths of the id number.

  • Maybe you are looking for

    • Depot Excise Invoice number skipped ???

      Hi Everyone For Ex. say our depot excise invoice number range is from 1to 100, assuming the current number is 51. Some day back there was a jump in the depot excise invoice number range. In between 1 and 51 the number "25" is missing. So the excise d

    • Using Time Capsule to Wirelessly Receive Internet and then Extend Network via Ethernet

      Hello, Our modem/router combo is located downstairs, and my computer that i want to get online is upstairs. I cannot get a ethernet from the modem to my computer to access the internet, so I wanted to try to use my Time Capsule to help me get online

    • Trying to backup my time machine..

      I am trying to backup my time machine but keeps coming up with error 6584 can anyone help please <Re-Titled By Host>

    • SQL Developer 3.2/4EA1 not fully reading TNSNAMES

      Hi, We are using both 3.2 and the 4EA1 versions, and have found that both are not fully reading the TNSNAMES file. In the TNSNAMES file, we have databases that are configured with either SID or SERVICENAME. It isn't excluding databases setup with eit

    • Erro in Webdynpro Abap

      Hi Experts, 1) I have designed one view with ui element label, textbox and command button. I have binded and do all the neccesities. while testing the application the out put is not visible in Internet explorer browser in both 6 .0 and 7. But the out