Sponsored Content
Top Forums Shell Programming and Scripting Extract a value from an xml file Post 302988325 by stomp on Friday 23rd of December 2016 02:05:20 PM
Old 12-23-2016
Hi,

I have some package here on my debian box which is called xml-twig-tools containing a program called xml_grep(a perl script) . I'm sure there are a bunch of xml-tools out there. I think within Solaris it would require to download some Perl Modules from CPAN for you and getting the script from here: xml_grep - search.cpan.org

With this tool I can do the following:

Code:
 xml_grep //PORTED_NUM --text_only your-file.xml

Output:
Code:
990-799-1234

or with xmlstarlet(a lot faster than the perl script, there's a package available for solaris) some compiled binary:
Code:
xmlstarlet sel -t -v //PORTED_NUM your-file.xml

If this is only a one-shot thing, you'll be better of with above awk or perl tips, since you do not have to fiddle with any installation. If you have more often to deal with XML those xmltools will help be a lot easier to handle.

Last edited by stomp; 12-23-2016 at 07:04 PM.. Reason: shortened xmlstarlet/xml_grep call with XPATH global search Pattern //
This User Gave Thanks to stomp For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract text from xml file

I have some xml files that got created by exporting a website from RedDot. I would like to extract the cost, course number, description, and meeting information. <?xml version="1.0" encoding="UTF-16" standalone="yes" ?> - <PAG PAG0="3AE6FCFD86D34896A82FCA3B7B76FF90" PAG3="525312"... (3 Replies)
Discussion started by: chrisf
3 Replies

2. UNIX for Dummies Questions & Answers

Extract Field Value from XML file

Hi, Within a UNIX shell script I need to extract a value from an XML field. The field will contain different values but will always be 6 digits in length. E.g.: <provider-id>999999</provider-id> I've tried various ways but no luck. Any ideas how I might get the provider id (in this case... (2 Replies)
Discussion started by: pnclayt11
2 Replies

3. Shell Programming and Scripting

Extract details from XML file

Hi , I have one xml file contains more than 60 lines. I need to extract some details from the file and store it in new file.Not the whole file Please find the xml file below: <?xml version="1.0" encoding="UTF-8"?> <DeploymentDescriptors xmlns="http://www.tibco.com/xmlns/dd"> ... (6 Replies)
Discussion started by: ckchelladurai
6 Replies

4. Shell Programming and Scripting

Extract XML content from a file

310439 2012-01-11 03:44:42,291 INFO PutServlet:? - Content of the Message is:="1.0" encoding="UTF-8"?><ESP_SSIA_ACC_FEED> 310440 <BATCH_ID>12345678519</BATCH_ID> 310441 <UID>3498748823</UID> 310442 <FEED_TYPE>FULL</FEED_TYPE> 310443 <MART_NAME>SSIA_DM_TRANSACTIONS</MART_NAME> 310444... (11 Replies)
Discussion started by: arukuku
11 Replies

5. Shell Programming and Scripting

extract a pattern from a xml file

Hello All, I want to write a shell script for extracting a content from a xml file the xml file looks like this: <Variable name="moreAxleInfo"> <type> <Table> <type> <NamedType> <type> <TypeRef... (11 Replies)
Discussion started by: suvendu4urs
11 Replies

6. Shell Programming and Scripting

Extract values from an XML File

Hi, I need to capture all the attributes with delete next to it. The source XML file is attached. The output should contain something like this below: Attributes = legacyExchangeDN Action = Delete Username = Hero Joker Loginid = joker09 OU =... (4 Replies)
Discussion started by: prvnrk
4 Replies

7. Shell Programming and Scripting

Extract XML tag value from file

Hello, Hope you are doing fine. I have an log file which looks like as follows: Some junk text1 Date: Thu Mar 15 13:38:46 CDT 2012 DATA SENT SUCCESSFULL: Some jun text 2 Date: Thu Mar 15 13:38:46 CDT 2012 DATA SENT SUCCESSFULL: ... (3 Replies)
Discussion started by: srattani
3 Replies

8. Shell Programming and Scripting

Extract data from XML file

Hi , I have input file as XML. following are input data #complex.xml <?xml version="1.0" encoding="UTF-8"?> <TEST_doc xmlns="http://www.w3.org/2001/XMLSchema-instance"> <ENTRY uid="123456"> <protein> <name>PROT001</name> <organism>Human</organism> ... (1 Reply)
Discussion started by: mohan sharma
1 Replies

9. 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

10. UNIX for Dummies Questions & Answers

Extract Element from XML file

<?xml version = '1.0' encoding =... (8 Replies)
Discussion started by: Siva SQL
8 Replies
RPC::XML::Method(3)					User Contributed Perl Documentation				       RPC::XML::Method(3)

NAME
RPC::XML::Method - Object encapsulation of server-side RPC methods SYNOPSIS
require RPC::XML::Method; ... $method_1 = RPC::XML::Method->new({ name => 'system.identity', code => sub { ... }, signature => [ 'string' ] }); $method_2 = RPC::XML::Method->new('/path/to/status.xpl'); DESCRIPTION
This package is no longer a distinct, separate entity. It has become an empty sub-class of RPC::XML::Procedure. Please see RPC::XML::Procedure for details on the methods and usage. By the time of 1.0 release of this software package, this file will be removed completely. BUGS
Please report any bugs or feature requests to "bug-rpc-xml at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RPC-XML <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=RPC-XML>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
o RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=RPC-XML <http://rt.cpan.org/NoAuth/Bugs.html?Dist=RPC-XML> o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/RPC-XML <http://annocpan.org/dist/RPC-XML> o CPAN Ratings http://cpanratings.perl.org/d/RPC-XML <http://cpanratings.perl.org/d/RPC-XML> o Search CPAN http://search.cpan.org/dist/RPC-XML <http://search.cpan.org/dist/RPC-XML> o Source code on GitHub http://github.com/rjray/rpc-xml/tree/master <http://github.com/rjray/rpc-xml/tree/master> COPYRIGHT &; LICENSE This file and the code within are copyright (c) 2009 by Randy J. Ray. Copying and distribution are permitted under the terms of the Artistic License 2.0 (http://www.opensource.org/licenses/artistic-license-2.0.php <http://www.opensource.org/licenses/artistic-license-2.0.php>) or the GNU LGPL 2.1 (http://www.opensource.org/licenses/lgpl-2.1.php <http://www.opensource.org/licenses/lgpl-2.1.php>). CREDITS
The XML-RPC standard is Copyright (c) 1998-2001, UserLand Software, Inc. See <http://www.xmlrpc.com> for more information about the XML- RPC specification. SEE ALSO
RPC::XML::Procedure AUTHOR
Randy J. Ray <rjray@blackperl.com> perl v5.12.1 2009-07-09 RPC::XML::Method(3)
All times are GMT -4. The time now is 01:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy