How to get a particular field from xml file?

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat How to get a particular field from xml file?
# 1  
Old 05-08-2013
How to get a particular field from xml file?

i have a xml file and in that input file path is given. how to fetch that input file

path using shell script.
# 2  
Old 05-08-2013
Sample text

I think you will need to post a sample of the xml file here, and what exactly you are trying to extract. Remember to wrap the sample data with CodeTags.
# 3  
Old 05-08-2013
my sample xml is
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Sources>
  <StopFileName>/export/home/merge/cfg/MergeConfig.xml.stop</StopFileName>
  <DatabaseConnection>
    <TNSName>dgid1rr</TNSName>
    <Username>rte</Username>
    <Password>rted1</Password>
  </DatabaseConnection>
  <Logger>
    <LogMaxSize>1024</LogMaxSize>
    <LogFileNos>5</LogFileNos>
    <LogFilePath>/export/home/dgid1rr/merge/log</LogFilePath>
    <LogFileName>idr_merge_log</LogFileName>
    <LogLevel>Info</LogLevel>
  </Logger>
  <Source id="S1">
    <FileMask>idr_%YYYY%%MM%%DD%_%N%.idr</FileMask>
    <TimeLag>100</TimeLag>
    <Backup>True</Backup>
    <InputFilePath>/export/home/dgid1rr/cdr1/input</InputFilePath>
    <OutputFilePath>/export/home/dgid1rr/merge/cdr1/output</OutputFilePath>
    <BackupFilePath>/export/home/dgid1rr/merge/cdr1/backup</BackupFilePath>
    <ProcessOrder>FileTimestamp</ProcessOrder>
    <Enable>True</Enable>
    <MaxFiles>3</MaxFiles>
    <MaxRecs>25</MaxRecs>
  </Source>
  <Source id="S2">
    <FileMask>idr_%2N%.idr</FileMask>
    <TimeLag>300</TimeLag>
    <Backup>True</Backup>
    <InputFilePath>/export/home/dgid1rr/merge/cdr2/input</InputFilePath>
    <OutputFilePath>/export/home/dgid1rr/merge/cdr2/output</OutputFilePath>
    <BackupFilePath>/export/home/dgid1rr/merge/cdr2/backup</BackupFilePath>
    <ProcessOrder>OSTimestamp</ProcessOrder>
    <Enable>True</Enable>
    <MaxFiles>2</MaxFiles>
  </Source>
</Sources>

what i have to do is to get input path from the xml.

Last edited by vgersh99; 05-08-2013 at 10:58 AM.. Reason: fixed icode tags - use code tags for multi-line text
# 4  
Old 05-08-2013
Try this one if you want only input file path
Code:
grep "InputFilePath" file | awk -F"<InputFilePath>|</InputFilePath>" '{ print $2}'

# 5  
Old 05-08-2013
Code:
awk -F'[<>]' '$2=="InputFilePath" {print $3}' myFile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Field delimited data to XML

Hi, We need to produce a XML file based on a record/field delimited data file. At this point we could just script something out but I would like to ask the community what would be the best choice of programming language to do this, in terms of performance of execution, and in terms of complexity... (9 Replies)
Discussion started by: Indalecio
9 Replies

2. Shell Programming and Scripting

Comparing delta values of one xml file in other xml file

Hi All, I have two xml files. One is having below input <NameValuePair> <name>Daemon</name> <value>tcp:7474</value> </NameValuePair> <NameValuePair> <name>Network</name> <value></value> </NameValuePair> ... (2 Replies)
Discussion started by: sharsour
2 Replies

3. Shell Programming and Scripting

Cgi to dump xml data from form input field

Hi All, I am trying to write a shell script which takes parse the web form find the input field and dump the data of that field into one xml file. The form looks like, <input type="button" id="btnSave" value="Save" onclick="saveXmlData()"/> <form name="submitForm"... (1 Reply)
Discussion started by: jdp
1 Replies

4. Shell Programming and Scripting

Help required in Splitting a xml file into multiple and appending it in another .xml file

HI All, I have to split a xml file into multiple xml files and append it in another .xml file. for example below is a sample xml and using shell script i have to split it into three xml files and append all the three xmls in a .xml file. Can some one help plz. eg: <?xml version="1.0"?>... (4 Replies)
Discussion started by: ganesan kulasek
4 Replies

5. Shell Programming and Scripting

How do I extract the third field in an xml entry?

I have the following XML entry - I need to extract the contents of the third defined variable, Asset_Name. <AMS Asset_Class="package" Asset_ID="XXXXXXXXXXXXXXXXXXXX" Asset_Name="MOVIE_XXXXXXXXXXX_XXXXXXXX" Creation_Date="2011-09-13" Description="test asset package" Product="MOD"... (4 Replies)
Discussion started by: hrr_mute
4 Replies

6. Shell Programming and Scripting

How to get a field from an XML?

We have an input XML of the following form <item> <account>1234</account> <id>345</id> </item> How do we get the value of <account> tag (1234) using UNIX ? (6 Replies)
Discussion started by: Jassz
6 Replies

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

8. Shell Programming and Scripting

Help needed XML Field Extraction

I had an immediate work to sort out the error code and error message which are associated within the log. But here im facing an problem to extract 3 different fields from the XML log can some one please help. I tried using different script including awk & nawk, but not getting the desired output. ... (18 Replies)
Discussion started by: raghunsi
18 Replies

9. Programming

Extracting Field values for XML file

i have an input file of XML type with data like <nx-charging:additional-parameter name="NX_INTERNATIONALIZED_CLID" value="919427960829"/><nx-charging:finalStatus>RESPONSE , Not/Applicable , OK</nx-charging:finalStatus></nx-charging:process> i want to extract data such that i get the output... (3 Replies)
Discussion started by: junaid.nehvi
3 Replies

10. Shell Programming and Scripting

How To Find Length of a Field in XML File

Hi I have a xml file with below data...have to find the length of the filedvalues... <?xml version="1.0" encoding="ISO-8859-15" standalone="no"?><abc xmlns:xsi="http://www.w3.org/2000/XMLSchem... (3 Replies)
Discussion started by: naughty21
3 Replies
Login or Register to Ask a Question