Extract data from XML file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Extract data from XML file

Shell Programming and Scripting


Tags
query result

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-28-2013
mohan sharma mohan sharma is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 1 March 2013, 1:54 AM EST
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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 08:53 AM..
Sponsored Links
    #2  
Old 02-28-2013
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 24 July 2014, 3:48 AM EDT
Posts: 1,156
Thanks: 20
Thanked 104 Times in 99 Posts
Please use code tags. Please post the output you are expecting from your sample input.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Data Extract from XML Log File raghunsi Shell Programming and Scripting 9 08-27-2010 11:13 PM
Extract data from an XML file & write into a CSV file ss_ss Shell Programming and Scripting 2 04-18-2010 09:21 PM
sed or awk to extract data from Xml file yeclota Shell Programming and Scripting 1 03-12-2009 08:15 AM
Help with shell script to extract data from XML file yajaykumar Shell Programming and Scripting 5 09-04-2008 12:28 AM
extract specific data from xml format file. 60doses Shell Programming and Scripting 7 01-16-2008 02:26 AM



All times are GMT -4. The time now is 07:42 AM.