Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Extract a specific number from an XML file based on the start and end tags Post 302357915 by sushant172 on Thursday 1st of October 2009 01:27:47 AM
Old 10-01-2009
Extract a specific number from an XML file based on the start and end tags

Hello People,

I have the following contents in an XML file

Code:
 
...........
...........
..........
...........
<Details = "Sample Details">
<Name>Bob</Name>
<Age>34</Age>
<Address>CA</Address>
<ContactNumber>1234</ContactNumber>
</Details>
...........
.............
...........
..........

Now, I need to extract the Details section with all the parameters i.e from

Code:
 
<Details = "Sample Details"> to
 
</Details>

and put in a separate temporary file.

Can I do it using the basic UNIX Shell commands i.e sed or cut or paste etc... ? Please help.

Thanks.

Last edited by zaxxon; 10-01-2009 at 03:19 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract specific data from xml format file.

Hi, I need to extract the start time value (bold, red font) under the '<LogEvent ID="Timer Start">' tag (black bold) from a file with the following pattern. There are other LogEventIDs listed in the file as well, making it harder for me to extract out the specific start time that I need. . .... (7 Replies)
Discussion started by: 60doses
7 Replies

2. Shell Programming and Scripting

extract a number within an xml file

Hi Everyone, I have an sh script that I am working on and I have run into a little snag that I am hoping someone here can assist me with. I am using wget to retrieve an xml file from thetvdb.com. This part works ok but what I need to be able to do is extract the series ID # from the xml and put... (10 Replies)
Discussion started by: tret
10 Replies

3. Shell Programming and Scripting

remove XML parent start and end tags in same file

Hi All, Requirement: remove start and end tag of parent element <DummyLevel> <level1> </level1> <level2> </level2> <level3> </level3> <level4> </level4> <level5> </level5> <level6> </level7> </DummyLevel> I have to delete the first <dummylevel> and last </DummyLevel> tags from... (7 Replies)
Discussion started by: dstage2006
7 Replies

4. Shell Programming and Scripting

Using SED/AWK to extract xml at end of file

Hello everyone, Firstly i do not require alot of help.. i am right at the end of finishing my scipt but cannot find a solution to the last part. What i need to do is, prompt the user for a file to work with, which i have done. promt the user for an output file - which is done. #!/bin/bash... (14 Replies)
Discussion started by: hugh86
14 Replies

5. Shell Programming and Scripting

The difference between end number in the early row and the start number in the next

Hi Power User, I'm trying to compute this kind of text file format: file1: jakarta 100 150 jakarta 170 210 beijing 220 250 beijing 260 280 beijing 290 320 new_york 330 350 new_york 370 420 tokyo 430 470 tokyo 480 ... (2 Replies)
Discussion started by: anjas
2 Replies

6. UNIX for Dummies Questions & Answers

extract regions of file based on start and end position

Hi, I have a file1 of many long sequences, each preceded by a unique header line. file2 is 3-columns list: headers name, start position, end position. I'd like to extract the sequence region of file1 specified in file2. Based on a post elsewhere, I found the code: awk... (2 Replies)
Discussion started by: pathunkathunk
2 Replies

7. Shell Programming and Scripting

How to extract start/end times from log file to CSV file?

Hi, I have a log file (log.txt) that which contains lines of date/time. I need to create a script to extract a CSV file (out.csv) that gets all the sequential times (with only 1 minute difference) together by stating the start time and end time of this period. Sample log file (log.txt) ... (7 Replies)
Discussion started by: Mr.Zizo
7 Replies

8. Shell Programming and Scripting

Extract specific lines based on another file

I have a folder containing text files. I need to extract specific lines from the files of this folder based on another file input.txt. How can I do this with awk/sed? file1 ARG 81.9 8 81.9 0 LEU 27.1 9 27.1 0 PHE .0 10 .0 0 ASP 59.8 11 59.8 0 ASN 27.6 12 27.6 0 ALA .0 13 .0 0... (5 Replies)
Discussion started by: alanmathew84
5 Replies

9. Shell Programming and Scripting

Extract the specific tags in a XML file

Hello Shell Gurus, I have a requirement to get the specific tags from a XML file. Here is my code snippet <jdbc-system-resource> <name>SDPData Source</name> <target>AdminServer,osb_server1,soa_server1</target> ... (30 Replies)
Discussion started by: Siv51427882
30 Replies

10. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies
PACEMAKER(8)						  System Administration Utilities					      PACEMAKER(8)

NAME
Pacemaker - Part of the Pacemaker cluster resource manager SYNOPSIS
crm_diff original_xml operation [options] DESCRIPTION
crm_diff - A utility for comparing Pacemaker configurations (XML format) The tool produces a custom (diff-like) output which it can also apply like a patch OPTIONS
-?, --help This text -$, --version Version information -V, --verbose Increase debug output Original XML: -o, --original=value XML is contained in the named file -O, --original-string=value XML is contained in the supplied string Operation: -n, --new=value Compare the original XML to the contents of the named file -N, --new-string=value Compare the original XML to the contents of the supplied string -p, --patch=value Patch the original XML with the contents of the named file Additional Options: -c, --cib Compare/patch the inputs as a CIB (includes versions details) -f, --filter Suppress irrelevant differences between the two inputs EXAMPLES
Obtain the two different configuration files by running cibadmin on the two cluster setups to compare: # cibadmin --query > cib-old.xml # cibadmin --query > cib-new.xml Calculate and save the difference between the two files: # crm_diff --original cib-old.xml --new cib-new.xml > patch.xml Apply the patch to the original file: # crm_diff --original cib-old.xml --patch patch.xml > updated.xml Apply the patch to the running cluster: # cibadmin --patch patch.xml AUTHOR
Written by Andrew Beekhof REPORTING BUGS
Report bugs to pacemaker@oss.clusterlabs.org Pacemaker 1.1.10-29.el7 June 2014 PACEMAKER(8)
All times are GMT -4. The time now is 07:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy