echo exact xml tag from an exact file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting echo exact xml tag from an exact file
# 1  
Old 10-30-2012
echo exact xml tag from an exact file

Im stumped on this one. Id like to echo into a .txt file all names for an xml feed in a huge folder. Can that be done?? Id need to echo <name>This name</name> in client.xml files.

Code:
$path="/mnt/windows/path"

echo 'recording names'

cd "$path"
for names in $path

than Im stuck on where to go and what would be best??
# 2  
Old 10-30-2012
I'm not sure what is your requirement, but if you are looking for a way to extract the data from your XML name tag, then here is how you do it:-

Code:
sed 's:^<name>\(.*\)</name>$:\1:' client.xml

# 3  
Old 10-31-2012
Quote:
Originally Posted by bipinajith
I'm not sure what is your requirement, but if you are looking for a way to extract the data from your XML name tag, then here is how you do it:-

Code:
sed 's:^<name>\(.*\)</name>$:\1:' client.xml

by any chance can you explain what is going on so I can better understand the process?

Edit:
Id like to undertstand this because I would like to extend something else Ive been working on and could use this as a variable for something else.

---------- Post updated 10-31-12 at 09:31 AM ---------- Previous update was 10-30-12 at 05:06 PM ----------

someone suggested xmllint but Im unsure how to use it in an echo for <name></name>


FOUND this while searching.

Last edited by graphicsman; 10-31-2012 at 12:01 PM..
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. UNIX for Dummies Questions & Answers

Grep exact IP address from file

I have a file with a lot of IP addresses in it named "address.list". address.list looks something like this: 10.77.50.11 10.77.50.110 10.77.50.111 a bunch more addresses For every IP address I need to grep another file to see if the IP address is in the other file: for x in `cat... (5 Replies)
Discussion started by: squoggle
5 Replies

3. Shell Programming and Scripting

How to add the multiple lines of xml tags before a particular xml tag in a file

Hi All, I'm stuck with adding multiple lines(irrespective of line number) to a file before a particular xml tag. Please help me. <A>testing_Location</A> <value>LA</value> <zone>US</zone> <B>Region</B> <value>Russia</value> <zone>Washington</zone> <C>Country</C>... (0 Replies)
Discussion started by: mjavalkar
0 Replies

4. Shell Programming and Scripting

QUESTION1: grep only exact string. QUESTION2: find and replace only exact value with sed

QUESTION1: How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed. Contents of car.txt CAR1_KEY0 CAR1_KEY1 CAR2_KEY0 CAR2_KEY1 CAR1_KEY10 CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1 grep... (1 Reply)
Discussion started by: thibodc
1 Replies

5. Shell Programming and Scripting

Want to grep exact pattern from file

Contents of my file is: DI DI DIR PHI I want to extract only DI. I am using below command grep -w DI <file> but it is also extracting DI. Can i use any other command to extract exact pattern where '[' does not have special meaning (4 Replies)
Discussion started by: nehashine
4 Replies

6. Shell Programming and Scripting

to get the exact word from the file using script

Hi everybody, I have one requirment, i have to get the particular server name from a file. EX: File contents will be like below.. $cat test.txt HostAssignments->new("server1", [ "PS_SERVER", "REG_SERVER", "PS_ORACLE", "OM_G10_AUD", "OM_G10_CAD", "OM_G10_CHF", ... (3 Replies)
Discussion started by: raghu.iv85
3 Replies

7. UNIX for Dummies Questions & Answers

How to find exact text in file ?

I have file named shortlist , and it contains this: 2233|charles harris |g.m. |sales |12/12/52| 90000 9876|bill johnson |director |production|03/12/50|130000 5678|robert dylan |d.g.m. |marketing |04/19/43| 85000 2365|john woodcock |director |personnel... (1 Reply)
Discussion started by: Cecko
1 Replies

8. UNIX for Dummies Questions & Answers

Exact path to a file

I uploaded a database file to Public_html of a virtual server using Unix and a dedicated ip address. I can reach it by browser in typing the address as xxx.xxx.xxx.xxx/Directoryname/databasename.dat . I am asked what I want to do, download or open. When I try to reach the file via a program... (2 Replies)
Discussion started by: timmendorf
2 Replies

9. Shell Programming and Scripting

Find Exact word in file

Hi ALL, I want to search one string “20 “ i.e 20 with space. But my file where I am searching this “20 “ contain some data like 120 before image file truncated 220 Reports section succeeded 20 Transaction database .prd stopped 220 Reports section completed. When I search for the... (5 Replies)
Discussion started by: Jeevan Salunke
5 Replies

10. Shell Programming and Scripting

Echo-exact

I'm new to this so please bear with me.. I have a program that generates a string of the binary data of an image. (I mean, if I take the output of the program, paste it into a text editor and save with a PNG extension, it's a valid image.) Now I want to take this string and pipe it into a... (1 Reply)
Discussion started by: matthewwithanm
1 Replies
Login or Register to Ask a Question