Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

remove a special character from the entire xml

Posted on 2015-01-23
6
Medium Priority
?
87 Views
Last Modified: 2015-01-25
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>
0
Comment
Question by:sri1209
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:brendanmeyer
ID: 40567906
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
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 40567923
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(., '^', '')"/>
0
 

Author Comment

by:sri1209
ID: 40568267
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,
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 40568441
it does not remove all the nodes, it processes the first one at the highest level and pushes out the text content of all nodes

You will need a template for processing the elements and one for processing the text

I can't test right now but

<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>

would be the template for processing all the element nodes

and this one would be the template for text nodes

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

Try the two together in the stylesheet
0
 

Author Comment

by:sri1209
ID: 40568541
thank you , it worked. thanks  a lot.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 40568918
welcome
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question