Sponsored Content
Full Discussion: Extract data from XML file
Top Forums Shell Programming and Scripting Extract data from XML file Post 302773507 by mohan sharma on Thursday 28th of February 2013 05:44:26 AM
Old 02-28-2013
Extract data from XML file

Hi ,
I have input file as XML. following are input data
#complex.xml
Code:
<?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>
      <class>cytoplasmic</class>
    </protein>
    <xrefs>
      <xref>
          <database>Ensembl</database>
          <accn>ENSG00000105829</accn>
      </xref>
      <xref>
          <database>UNIPROT</database>
          <accn>Q12345</accn>
      </xref>
    </xrefs>
  </ENTRY>
  <ENTRY uid="45678">
    <protein>
      <name>PROT002</name>
      <organism>Human</organism>
      <class>nuclear</class>
    </protein>
    <xrefs>
      <xref>
          <database>Ensembl</database>
          <accn>ENSG00000105333</accn>
      </xref>
      <xref>
          <database>UNIPROT</database>
          <accn>Q14789</accn>
      </xref>
    </xrefs>
  </ENTRY>
</TEST_doc>

i want to extract data from this file and i tried below query.
cat complex.xml | xml sel -t -m //xref -v "concat(../../protein/name,' ',../../protein/class,' ',./database,' ',./accn)" -n

but it is not giving any output...but this query is working when instead of xmlns i am writing xmlns:xsi="...."
but my input file is having only xmlns="..."

please help me ...

Last edited by fpmurphy; 02-28-2013 at 09:53 AM..
 

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

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

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

4. Shell Programming and Scripting

XML data extract

Hi all, I have the following xml document : <HEADER><El1>asdf</El1> <El2>3</El2> <El3>asad</El3> <El4>asasdf</El4> <El5>asdf</El5> <El6>asdf</El6> <El7>asdf</El7> <El8>A</El8> <El9>0</El9> <El10>75291028141917</El10> <El11>asdf</El11> <El12>sdf</El12> <El13>er</El13> <El14><El15>asdf... (1 Reply)
Discussion started by: nthed
1 Replies

5. Shell Programming and Scripting

Extract data from an XML file & write into a CSV file

Hi All, I am having an XML tag like: <detail sim_ser_no_1="898407109001000090" imsi_1="452070001000090"> <security>ADM1=????</security> <security>PIN1=????</security> <security>PIN2=????</security> ... (2 Replies)
Discussion started by: ss_ss
2 Replies

6. Shell Programming and Scripting

Data Extract from XML Log File

Please help me out to extract the Data from the XML Log files. So here is the data ERROR|2010-08-26 00:05:52,958|SERIAL_ID=128279996|ST=2010-08-2600:05:52|DEVICE=113.2.21.12:601|TYPE=TransactionLog... (9 Replies)
Discussion started by: raghunsi
9 Replies

7. Shell Programming and Scripting

Extract data from XML file and write in CSV file

Hi friend i have input as following XML file <?xml version="1.0"?> <Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.054.001.02"> <BkToCstmrDbtCdtNtfctn> <GrpHdr><MsgId>LBP-RDJ-TE000000-130042430010001001</MsgId><CreDtTm>2013-01-04T03:21:30</CreDtTm></GrpHdr>... (3 Replies)
Discussion started by: mohan sharma
3 Replies

8. Shell Programming and Scripting

How to extract data from xml file using shell scripting?

Hi evry1, This is my 1st post in this forum.Pls help me I want to extract some data froma xml file which has 2000 lines using shell scripting. Actually my xml file has some "audio and video codes" which i need to arrange in a column wise format after extracting it using shell scripting.I... (4 Replies)
Discussion started by: arun_kohan
4 Replies

9. Shell Programming and Scripting

How to extract data from XML file using shell scripting?

Hi , I have input file as XML. following are input data #complex.xml Code: <?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: arun_kohan
1 Replies

10. Shell Programming and Scripting

Extract Data from XML file.

Hi Guys, I am in a need to extract data from a xml file. The XML file format is as below. <data jsxnamespace="propsbundle" locales=""> <locale> <!--Error messages starts--> <record jsxid="CHARPAIR001" jsxtext=" must be selected"></record> <record... (1 Reply)
Discussion started by: Showdown
1 Replies
XML::SAX::ExpatXS(3pm)					User Contributed Perl Documentation				    XML::SAX::ExpatXS(3pm)

NAME
XML::SAX::ExpatXS - Perl SAX 2 XS extension to Expat parser SYNOPSIS
use XML::SAX::ExpatXS; $handler = MyHandler->new(); $parser = XML::SAX::ExpatXS->new( Handler => $handler ); $parser->parse_uri($uri); #or $parser->parse_string($xml); DESCRIPTION
XML::SAX::ExpatXS is a direct XS extension to Expat XML parser. It implements Perl SAX 2.1 interface. See http://perl-xml.sourceforge.net/perl-sax/ for Perl SAX API description. Any deviations from the Perl SAX 2.1 specification are considered as bugs. Features The parser behavior can be changed by setting features. $parser->set_feature(FEATURE, VALUE); XML::SAX::ExpatXS provides these adjustable features: "http://xmlns.perl.org/sax/join-character-data" Consequent character data are joined (1, default) or not(0). "http://xmlns.perl.org/sax/ns-attributes" Namespace attributes are reported as common attributes (1, default) or not(0). "http://xmlns.perl.org/sax/xmlns-uris" When set on, xmlns and xmlns:* attributes are put into namespaces in a Perl SAX traditional way; xmlns attributes are in no namespace while xmlns:* attributes are in the "http://www.w3.org/2000/xmlns/" namespace. This feature is set to 1 by default. "http://xml.org/sax/features/xmlns-uris" This feature applies if and only if the "http://xmlns.perl.org/sax/xmlns-uris" feature is off. Then, xmlns and xmlns:* attributes are both put into no namespace (0, default) or into "http://www.w3.org/2000/xmlns/" namespace(1). "http://xmlns.perl.org/sax/locator" The document locator is updated (1, default) for ContentHadler events or not(0). "http://xmlns.perl.org/sax/recstring" A recognized string (the text string currently processed by this XML parser) is either maintained as $parser->{ParseOptions}{RecognizedString} (1) or not (0, default). "http://xml.org/sax/features/external-general-entities" Controls whether this parser processes external general entities (1, default) or not(0). "http://xml.org/sax/features/external-parameter-entities" Controls whether this parser processes external parameter entities including an external DTD subset(1) or not (0, default). Constructor Options Apart from features, the behavior of this parser can also be changed with options to the constructor. ParseParamEnt ParseParamEnt => 1 This option meaning is exactly the same as the "http://xml.org/sax/features/external-parameter-entities" feature. The option is supported only because of the compatibility with older versions of this module. Turned off by default. NoExpand NoExpand => 1 No internal entities are expanded if this option is turned on. Turned off by default. Read-only Properties ExpatVersion This property returns a version of linked Expat library, for example expat_1.95.7. AUTHORS
Petr Cimprich <petr AT gingerall DOT org> (maintainer) Matt Sergeant <matt AT sergeant DOT org> perl v5.14.2 2011-04-12 XML::SAX::ExpatXS(3pm)
All times are GMT -4. The time now is 07:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy