How to replace value of password tag in xml with blanks when special characters are there?


 
Thread Tools Search this Thread
Contact Us Post Here to Contact Site Administrators and Moderators How to Post in the The UNIX and Linux Forums How to replace value of password tag in xml with blanks when special characters are there?
# 8  
Old 10-27-2015
sub in an awk statement, yes. gsub isn't necessary, I realized, just plain sub. So if you're doing 37 operations in awk already, you could just add one more for less performance hit than adding another pipe chain.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies

2. Shell Programming and Scripting

sed search and replace after xml tag

Hi All, I'm new to sed. In following XML file <interface type='direct'> <mac address='52:54:00:86:ce:f6'/> <source dev='eno1' mode='bridge'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> ... (8 Replies)
Discussion started by: varunrapelly
8 Replies

3. Shell Programming and Scripting

Need to replace XML TAG

As per the requirement I need to replace XML tag with old to new on one of the XML file. Old<com : DEM>PHI</com : DEM> New<com : DEM>PHM</com : DEM> Please someone provide the sed command to replace above mentioned old XML tag with new XML tag (2 Replies)
Discussion started by: siva83
2 Replies

4. Shell Programming and Scripting

Find out special characters from xml file

Hi....I have a xml file which is having lots of special characters which I need to find out and put the distinct list of those into a text file. The list of special characters is not specific, it can be anything at different point of time. Can anyone help me to find out the same and list out? ... (10 Replies)
Discussion started by: Krishanu Saha
10 Replies

5. AIX

special characters in front of xml declaration

Hi I read xml files through mq and placed them on unix by using datastage as tool. I can see some special characters infront of declaration part for every xml file i have produced. below is the sample snippet when i opened the file by suing vi editor ^Z^E|^A^Z^Z<?xml version="1.0"... (1 Reply)
Discussion started by: dsdev_123
1 Replies

6. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

7. Solaris

How to replace special characters in vi?

Hi , I want to replace the special characters in the file. For eg: cat abc 1234/4455/acb 234/k/lll/ 234`fs`fd I want to replace / and ` with the letter a and the output should like below. How to achieve this. 1234a4455aacb 234akallla 234afsafd (2 Replies)
Discussion started by: rogerben
2 Replies

8. UNIX for Dummies Questions & Answers

replace characters with spaces between tag

I have a file where in some records are having the <Start> and <End> tag. There is data before the start tag , between the tages and after the End tag. I want to replace everything between the start & end tag with equivalent spaces. Input File afsdfaksddfs<start>12678<end>sgdfgdfsf... (6 Replies)
Discussion started by: varunrbs
6 Replies

9. UNIX for Dummies Questions & Answers

printing password having special characters

Hi I have a password stored in a file (which is a user input) The password is having the special character $ say the password is pw$ord and is stored in the file pw_note I am using the following statement to store the passowrd in a variable $schema_pwd = `cat $dir/pwd_note` ; Now if i print... (4 Replies)
Discussion started by: ssuresh1999
4 Replies

10. UNIX for Dummies Questions & Answers

Parsing special characters between C and XML..

Hi, I am getting problem in parsing special characters(Like &, > or <) in XML. I need to encode my C program and send in report format to another interface which is in XML format. I do not know how to encode these special characters in C program before sending to XML format. Please help !! (1 Reply)
Discussion started by: ronix007
1 Replies
Login or Register to Ask a Question
XML::Smart::Tutorial(3pm)				User Contributed Perl Documentation				 XML::Smart::Tutorial(3pm)

NAME
XML::Smart::Tutorial - Tutorial and examples for XML::Smart. SYNOPSIS
This document is a tutorial for XML::Smart and shows some examples of usual things. Working with contents: In XML::Smart the key CONTENT is reserved and shouldn't be used directly, since XML::Smart will deal with the convertion of arguments to node contents, including multiple node contents autimatically. What happens when you set a value: $xml->{root}{foo} = 'simple value' ; Here foo will be a normal argument/attribute value, and will generate this XML data: <root foo="simple value"/> But if you insert some tag or lines in the values by default XML::Smart will convert it to a node content: $xml->{root}{foo} = "line0 lien1 line2 " ; And will generate that XML data: <root> <foo>line0 lien1 line2 </foo> </root> But what you can do if you want to force some type, let's say, have a node content with a simple value: $xml->{root}{foo} = 'simple value' ; $xml->{root}{foo}->set_node(1) ; And will generate that XML data: <root> <foo>simple value</foo> </root> Multiple contents: When you have interpolated content/data you need to work in a different. Let's say that you load this XML data: <root> content0 <tag1 arg="1"/> content1 </root> If you access directly the root key as string you will get all the content parts grouped. So, this code: my $xml = new XML::Smart(q` <root> content0 <tag1 arg="1"/> content1 </root> `,'smart') ; print "#$xml->{root}#" ; Will print that: # content0 content1 # To access each part of the content independently you should use an array that receive the method content(): my @content = $xml->{root}->content ; print "#$content[0]# " ; And this will print that: # content0 # Now to set the multiple content values you should use the method content() with 2 arguments: $xml->{root}->content(0,'new content') ; And now the XML data produced will be: <root>new content<tag1 arg="1"/> content1 </root> If you use the method content() with only one argument it will remove all the multiple contents and will set the new value in the place of the 1st content. Setting the XML Parser. By defaul XML::Smart will use XML::Parser or XML::Smart::Parser (in this order of preference) to load a XML data. To force or define by your self the parser you can use the 2nd argument option when creating a XML::Smart object: my $xml = new XML::Smart( 'some.xml' , 'XML::Parser' ) ; ## and my $xml = new XML::Smart( 'some.xml' , 'XML::Smart::Parser' ) ; XML::Smart also has an extra parser, XML::Smart::HTMLParser, that can be used to load HTML as XML, or to load wild XML data: my $xml = new XML::Smart( 'some.xml' , 'XML::Smart::HTMLParser' ) ; Aliases for the parser options: SMART|REGEXP => XML::Smart::Parser HTML => XML::Smart::HTMLParser So, you can use as: my $xml = new XML::Smart( 'some.xml' , 'smart' ) ; my $xml = new XML::Smart( 'some.xml' , 'html' ) ; Customizing the Parser. You can customize the way that the parser will treat the XML data: Forcing nodes/tags and arguments/attributes to lowercase or upercase: ## For lower case: my $xml = new XML::Smart( 'some.xml' , lowtag => 1 , lowarg => 1 , ) ; ## For uper case: my $xml = new XML::Smart( 'some.xml' , upertag => 1 , uperarg => 1 , ) ; Loading arguments without values (flags) as a TRUE boolean: ** Note, this option will work only when the XML is parsed by XML::Smart::HTMLParser, since only it accept arguments without values! my $xml = new XML::Smart( '<root><foo arg1="" flag></root>' , 'XML::Smart::HTMLParser' , arg_single => 1 , ) ; Here's the tree of the example above: 'root' => { 'foo' => { 'flag' => 1, 'arg1' => '' }, }, Customizing the parse events: XML::Smart can redirect the parsing process to personalized functions: my $xml = XML::Smart->new( 'some.xml' , on_start => &on_start , on_char => &on_char , on_end => &on_end , ) ; sub on_start { my ( $tag , $pointer , $pointer_back ) = @_ ; $pointer->{$tag}{type_user} = 1 if $tag =~ /(?:name|age)/ ; } sub on_char { my ( $tag , $pointer , $pointer_back , $content) = @_ ; $$content =~ s/s+/ /gs ; } sub on_end { my ( $tag , $pointer , $pointer_back ) = @_ ; $pointer->{$tag}{type_extra} = 1 if $tag =~ /(?:more|tel|address)/ ; } AUTHOR
Graciliano M. P. <gm@virtuasites.com.br> I will appreciate any type of feedback (include your opinions and/or suggestions). ;-P Enjoy and thanks for who are enjoying this tool and have sent e-mails! ;-P ePod This document was written in ePod (easy-POD), than converted to POD, and from here you know the way. perl v5.10.1 2004-12-08 XML::Smart::Tutorial(3pm)