Perl: Question about stripping tags


 
Thread Tools Search this Thread
Top Forums Programming Perl: Question about stripping tags
# 1  
Old 04-10-2012
Perl: Question about stripping tags

hey 1 more question, how do you strip tags like <p></p> from output of xml with perl?

i already strip the CDATA but the annoying <p></p> still there

Last edited by jim mcnamara; 04-10-2012 at 08:04 AM.. Reason: Title change
# 2  
Old 04-10-2012
Code:
[user@cygwin ~]$ cat input
<note>
    <to>John</to>
    <from>Jack</from>
    <heading>Hello</heading>
    <body>Howdy</body>
</note>
[user@cygwin ~]$ perl -pe 's/<.+?>//g' input

    John
    Jack
    Hello
    Howdy

[user@cygwin ~]$

If you want more accurate solutions, please post a sample input file and desired output.
# 3  
Old 04-10-2012
lets see, for example

Code:
<title>NICK</title>
<description><![CDATA[<p>Thanks alot for helping.</p>]]>
<date>today</date>
<link>hi</link>

for my program i output
Code:
----------------------------------------------------------
Title:         Nick
date:          today
link:           hi
<p>Thanks alot for helping</p>

the" Description: "is gone and there's <p></p>
the "Description: " disappear i assume it's because of the tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Stripping ret of the lines in a file (sed question)

Hi all, I didn't use SED for 20 years and was never an expert. So my current knowledge is about zero. Please be patient with me. I'm neither a native speaker. I have a huge dictionary file and want the rest of the lines stripped. Everything after (and including) the "/" should be stripped. I... (2 Replies)
Discussion started by: Hinnerk2005
2 Replies

2. Solaris

Diffrence between stripping and mirroring

Hi All, What is the difference between stripping and mirroring? Thanks, Rafi. (3 Replies)
Discussion started by: rafidba.alvi
3 Replies

3. UNIX for Dummies Questions & Answers

Stripping down binaries

Hello, I am the CEO of Grand Tech Corporation. We are launching Linux NT and forgive me, but I do not know how to strip binaries down in Mandriva Linux. Can someone tell me a way to?:b: (2 Replies)
Discussion started by: Linux NT
2 Replies

4. Shell Programming and Scripting

stripping a variable down

I have a variable that has an absolute path for a file on my computer. This dynamically changes. Is there a way I can assign two new variables from that one? variable: /Users/keith/Desktop/test/file.mov 1) filename - no path or extention ....so just....file 2) path no filename or... (3 Replies)
Discussion started by: mainegate
3 Replies

5. Shell Programming and Scripting

Stripping out extension in file name

This command gives me just the filename without any extension: evrvar =`echo filename.tar | sed 's/\.*$//'` I am trying to make a change to this command... to make it work for... filename.tar.gz to get just the filename.... currently the command gives me filename.tar by removing only gz... I... (9 Replies)
Discussion started by: devs
9 Replies

6. Shell Programming and Scripting

stripping white space...

Hi All; Having a problem with a file.. the file contains the following data... (a snapshot) 1331F9E9DB7C2BB80EAEDE3A8F043B94,AL7 1DZ,M,50 186FDF93E1303DBA217279EC3671EA91,NG5 1JU,M,24 3783FFAF602015056A8CD21104B1AAAF,CH42 4NQ,M,17 It has 3 columns sepreated by a , the second column... (7 Replies)
Discussion started by: Zak
7 Replies

7. UNIX for Dummies Questions & Answers

Stripping all content but an integer

Hello! I have content in a log file that consists of a lot of spaces before and after a 3 digit integer which I need to strip out before I can use the file. The number of digits can change. When I had my logic in a 'for' loop and could output into another file, it was fine. but it turns out... (10 Replies)
Discussion started by: tekster757
10 Replies

8. Shell Programming and Scripting

stripping out certain charecters

we are ftping zipped up files from the development server to the production server daily.The files are in this format filename.dat.20061231.12131.gz I have to unzip the file (i can do that with gunzip) and then strip out the timestamp after the .dat extension. I can do something like this ... (4 Replies)
Discussion started by: mervin2006
4 Replies

9. UNIX for Dummies Questions & Answers

stripping server name from path

can anyone help me with stripping an absolute filepath? I did a search on this topic but didnt find anything but maybe I didn't look hard. Anyway, would really appreciate it if anyone could help me. I am a new unix user so this might be a simple issue but I am stuck, don't really understand the use... (4 Replies)
Discussion started by: Ecclesiastes
4 Replies

10. UNIX for Dummies Questions & Answers

stripping last lien off a file

Hi, how can i strip the last line off my file using shell script? Thanks and Regards Vivek.S (3 Replies)
Discussion started by: vivekshankar
3 Replies
Login or Register to Ask a Question