How to Remove Blank Spaces after using remove

2011-02-05
2013-05-15
  • Vinaya Kumar

    Vinaya Kumar - 2011-02-05

    Hello Sir,
    Thanks for your help
    After we delete some values  from the xml, that place in the xml becomes blank. Please help in this regard
    For Eg:
    Say we have contacts 1,2 and 3 are there in the xml and we have deleted 2. There is a gap of one entry space between 1 and 3.
    how to remove  blank spaces in xml.

    Here is my code sinppet :-

    while ((i=autoPilot.evalXPath()) !=-1) {
    xm.remove();
    }
      

     
  • jimmy zhang

    jimmy zhang - 2011-02-08

    Can you provide a more concrete example?

     
  • Vinaya Kumar

    Vinaya Kumar - 2011-02-15

    <?xml version="1.0" encoding="UTF-8"?>
    <contact-list xmlns=" urn:ietf:params:xml:ns:contact-lists">
    <list name="oma_list">
    <entry uri=”tel+12147654212”>
                <display-name>Contact1</display-name>
               <display-name>contact2</display-name>
                <display-name>contact3</display-name>
    </entry>
    </list>
    <contact-list>

    if  i use above xml file

    out put after using remove method

    <?xml version="1.0" encoding="UTF-8"?>
    <contact-list xmlns=" urn:ietf:params:xml:ns:contact-lists">
    <list name="oma_list">
    <entry uri=”tel+12147654212”>
                                                               ===> blank white space …

    </entry>
    </list>
    <contact-list>

    how to remove blank white space.. ?

     
  • Vinaya Kumar

    Vinaya Kumar - 2011-02-18

    Hi could u provide reply asap..

     
  • jimmy zhang

    jimmy zhang - 2011-02-27

    ok, will look into it and get back

     
  • jimmy zhang

    jimmy zhang - 2011-03-01

    you should use xmlmodififer's remove(vn.getContentFragment()) method at the entry node

     
  • Vinaya Kumar

    Vinaya Kumar - 2011-03-04

    thanks for the help, But when i want try to delete entire display-name then how ? Here is explanation:

    i use the method remove() for removing particular element completely,Here is the example :

    Input XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists">
    <list name="oma_pocbuddylist">
    <entry uri="tel:+99999">
                <display-name>Contact8</display-name>
           <displays-name>Contact 9</displays-name>
    </entry>
    ……

    Where :
    XPath :"/resource-lists/list/entry/display-name"

    Then Output:
    <?xml version="1.0" encoding="UTF-8"?>
    <resource-lists xmlns="urn:ietf:params:xml:ns:resource-lists">
    <list name="oma_pocbuddylist">
    <entry uri="tel:+99999">
                                                                ===================> here is the empty blank space to be removed.
    <displays-name>Contact 9</displays-name>
    </entry>

    Here in this place i cant use remove(vn.getContentFragment()); so i need one method to remove entire particular element and remove blank spaces too .Could u suggest me how to approach for it.

     
  • jimmy zhang

    jimmy zhang - 2011-03-05

    if the outcome looks like below, is it acceptable?
    <entry uri="tel:+99999"><displays-name>Contact 9</displays-name></entry>

     
  • Vinaya Kumar

    Vinaya Kumar - 2011-03-07

    Yes ,that's to be fine for now

     
  • Vinaya Kumar

    Vinaya Kumar - 2011-03-22

    Sir,
    Requesting u post the solution asap.

     
  • jimmy zhang

    jimmy zhang - 2011-03-22

    It does not seem like a piece of code, but rather a patch in an upcoming release

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks