none
XML file - removing node value RRS feed

  • Question

  • Hi there,

    I have an XML file and I would like to remove all values. I have tried to set them to empty string but in result I got new line

    Orignal file

    <userName>AA11BB</userName>
    <numberOfEntries>1</numberOfEntries>
    <entries>
       <entry objectType="GlobalRole" name="AR30983" />
    </entries>
    
    What I got
    <userName>
    </userName>
    <numberOfEntries>
    </numberOfEntries>
    <entries>
       <entry objectType="GlobalRole" name="AR30983" />
    </entries>
    

    and what I need

    <userName></userName>
    <numberOfEntries></numberOfEntries>
    <entries>
       <entry objectType="GlobalRole" name="AR30983" />
    </entries>
    

    Friday, July 29, 2016 9:07 AM

Answers

  • There is no technical difference between what you have and what you want. It is just output format that is different.  Format is not important to an XML file.

    Perhaps if you explain why we could point you in the right direction.

    By the way.  A correct empty element would look like this.

    <username/>
    <numberOfEntries/>
    <entries>
       <entry objectType="GlobalRole" name="AR30983"/>
    </entries>

    Empty elements use self closing tags  although an empty tag on one or more lines works the same way.

    XML files are not really text files. They are structured data files.


    \_(ツ)_/

    • Marked as answer by Marek Lotocki Thursday, August 4, 2016 6:47 AM
    Friday, July 29, 2016 10:32 AM