Link to home
Start Free TrialLog in
Avatar of sri1209
sri1209

asked on

remove a special character from the entire xml

i Have an xml with the following format, the thing is need to replace a character "^" ( with a space or remove it) the character can repeat  in many child nodes, is there a way to remove that special character from whole of the xml (i.e) from root node.


<Details>
                        <Cash>
                                    <TitleLogo> xxxxxx</TitleLogo>
                                    <Title> xxxxxxxxxxx</Title>
                                    <Approval>
                                                <Title>xxx</Title>
                                                <TitleLogo>xxx</TitleLogo>
                                                <Header1>xxx</Header1>
                                                <Header2>xxx</Header2>
                                                <Header3>xxx</Header3>
                                                <Qualified>
                                                            <Person>
                                                                        <Names>xxxxxx</Names>
                                                                        <When>xxxxx</When>
                                                                        <HowMuch>xxxxx</HowMuch>
                                                            </Person>
                                                </Qualified>
                                                <Footer>xxxxxxx</Footer>
                                    </Approval>
                        </Cash>
                       
<Details>
Avatar of Brendan M
Brendan M
Flag of Australia image

copy the data to a notepad and do a replace for that character to either the space or nothing
copy it back, and save
i would make sure i have a backup first
1. I would highly recommend against brendanmeyer's suggestion. One thing that makes XML a good information exchange format is the fact that it has a very reliable encoding mechanism. Opening and saving an XML in notepad most always leads to character encoding problems (unless you are 100% sure you are only using safe characters). If you would do it this way, use an XML editor instead of notepad.

2. If this is in the context of the XSLTs you are developing... make sure you have a template for text() nodes and inside that template do a <xsl:value-of select="translate(., '^', '')"/>
Avatar of sri1209
sri1209

ASKER

Hi  Geert Bormans,

 i have tried the following but it doesnt translate , i am a little dumb on xslt, could you please let me know if this is correct


 <xsl:template match="node()">
        <xsl:copy>
                        <xsl:value-of select="translate(., '^', '')"/>
        </xsl:copy>
    </xsl:template>

it removes all the nodes,
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sri1209

ASKER

thank you , it worked. thanks  a lot.