Sponsored Content
Full Discussion: sed extract from xml
Top Forums Shell Programming and Scripting sed extract from xml Post 302530836 by garboon on Wednesday 15th of June 2011 05:18:36 AM
Old 06-15-2011
sed extract from xml

I have an xml file that generally looks like this:
Code:
"<row><dnorpattern>02788920</dnorpattern><description/></row><row><dnorpattern>\+
44146322XXXX</dnorpattern><description/></row><row><dnorpattern>40[6-9]XXX</dnorpattern><description/></row><row><dnorpattern>11</dn
orpattern><description/></row><row><dnorpattern>9710</dnorpattern><description/></row><row><dnorpattern>755.XXXXX</dnorpattern><desc
ription/></row><row><dnorpattern>00</dnorpattern><description/></row><row><dnorpattern>02754115</dnorpattern><description/></row><ro
w><dnorpattern>456XXX</dnorpattern><description/></row><row><dnorpattern>\+44551665XXXX</dnorpattern><description/></row><row><dnorpattern>02785XXX</dnorpattern><description/></row><row><dnorpattern>99999</dnorpattern><description/></row>"

I want to extract all the dnorpatterns here and am very close with this:
Code:
sed -n -e 's/.*<dnorpattern>\(.*\)<\/dnorpattern>.*/\1/p'

This grabs the dnorpattern but I am only getting the last one.
I think it's actually grabbing them all but overwritting with each new instance so I only end up with the last instance in the file.
I think I need to use i or a here somewhere but I can't quite figure out where to put it.

How would I add a new line after each instance in the output stream so that I get all instances listed?

Last edited by Franklin52; 06-15-2011 at 06:23 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

· simerian · XML Extract

The script following in this thread allows XML data to be located and extracted in a variety of forms from an XML data stream. Using this utility, it is possible to extract all manner of XML subsets and allow data to be post inserted into the "original" XML at any logical point. The pipe is... (2 Replies)
Discussion started by: Simerian
2 Replies

2. Shell Programming and Scripting

sed or awk to extract data from Xml file

Hi, I want to get data from Xml file by using sed or awk command. I want to get the following result : mon titre 1;Createur1;Dossier1 mon titre 1;Createur1;Dossier1 and save it in cvs file (fichier.cvs). FROM this Xml file (test.xml): <playlist version="1"> <trackList> <track>... (1 Reply)
Discussion started by: yeclota
1 Replies

3. Shell Programming and Scripting

SED extract XML value

I have the following string: <min-pool-size>2</min-pool-size> When I pipe the string into the following code I am expcting for it to return just the value "2", but its just reurning the whole string. Why?? sed -n '/<min-pool-size>/,/<\/min-pool-size>/p' Outputting:... (13 Replies)
Discussion started by: ArterialTool
13 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

Extract value from XML

I have a file like below <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:executeMDXResponse... (9 Replies)
Discussion started by: manas_ranjan
9 Replies

6. Shell Programming and Scripting

Extract Multivalue from XML

I have below attached xml file , how can I have my desired output as below. i/p file <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:executeMDXResponse... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

7. Shell Programming and Scripting

sed - extract text from xml file

hi, please help, i have an xml file, e.g: ... <tag> test text asdas="${abc}" xvxvbs:asdas${222}sdad asasa="${aa_bb_22}" </tag> ... i want to extract all "${...}", e.g: ${abc} ${222} ${aa_bb_22} thank you. (2 Replies)
Discussion started by: gioni
2 Replies

8. Shell Programming and Scripting

Extract a particular xml only from an xml jar file

Hi..need help on how to extract a particular xml file only from an xml jar file... thanks! (2 Replies)
Discussion started by: qwerty000
2 Replies

9. Shell Programming and Scripting

Extract strings from XML files and create a new XML

Hello everybody, I have a double mission with some XML files, which is pretty challenging for my actual beginner UNIX knowledge. I need to extract some strings from multiple XML files and create a new XML file with the searched strings.. The original XML files contain the source code for... (12 Replies)
Discussion started by: milano.churchil
12 Replies

10. Shell Programming and Scripting

Extract a value from an xml file

I have this XML file format and all in one line: Fri Dec 23 00:14:52 2016 Logged Message:689|<?xml version="1.0" encoding="UTF-8"?><PORT_RESPONSE><HEADER><ORIGINATOR>XMG</ORIGINATOR><DESTINAT... (16 Replies)
Discussion started by: mrn6430
16 Replies
MAVEN(1)							   User Commands							  MAVEN(1)

NAME
Maven - Installs site.xml into /usr/share/maven-repo. SYNOPSIS
mh_installsite [option]... [pom] [site-file] DESCRIPTION
Installs the site.xml file in /usr/share/maven-repo, at the correct location for Maven. Where [pom] is the location of the POM associated with the site.xml file to install. GroupId, artifactId and version will be extracted from this file. [site-file] is the location of the site.xml to install. OPTIONS
-h --help: show this text -V --version: show the version -p<package> --package=<package>: name of the Debian package which will contain the site file -e<version>, --set-version=<version>: set the version for the artifact, do not use the version declared in the POM file. -r<rules> --rules=<rules>: path to the file containing the rules to apply when cleaning the POM. Optional, the default location is debian/maven.rules Maven rules are used here to extract the groupId, artifactId and version from the POM file. -v --verbose: show more information while running -n --no-act: don't actually do anything, just print the results --skip-clean-pom: don't clean the pom, assume that a previous action ran mh_cleanpom with the correct options. mh_cleanpom is run only to extract the groupId, artifactId and version of the jar See also: mh_installpom(1), mh_installjar(1) Maven Repo Helper version 1.7.1 January 2012 MAVEN(1)
All times are GMT -4. The time now is 12:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy