Sponsored Content
Top Forums Programming Extracting Field values for XML file Post 302301262 by junaid.nehvi on Thursday 26th of March 2009 10:46:14 AM
Old 03-26-2009
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-chargingSmilierocess>

i want to extract data such that i get the output like:

additional-parameter name=NX_INTERNATIONALIZED_CLID
value=919427960829
finalStatus=RESPONSE Not/Applicable , OK


i have done some coding for it

#include <stdio.h>
#include <string.h>

int main()
{

char DataIn[] = "<nx-charging:additional-parameter name=\"NX_INTERNATIONALIZED_CLID\" value=\"919427960829\"/><nx-charging:finalStatus>RESPONSE , Not/Applicable , OK</nx-charging:finalStatus></nx-chargingSmilierocess>";

char *str = DataIn;
char *token;
while ( (token = strtok ( str, ":<>/" )) )
{
puts(token);
str = 0;
}
return 0;
}

But my output comes as:

/***OUTPUT*****

nx-charging
additional-parameter name="NX_INTERNATIONALIZED_CLID" value="919427960829"
nx-charging
finalStatus
RESPONSE , Not
Applicable , OK
nx-charging
finalStatus
nx-charging
process




the fields highlighted are not required by me.

Plus the fields

finalStatus
RESPONSE , Not
Applicable , OK

should come as

finalStatus=RESPONSE Not/Applicable , OK

please suggest me some changes.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extracting XML file using sed

Hello folks I want to extract data between certain tag in XML file using 'sed' <xml> ......... .......... <one>XXXXXXXXXXXXXXXXXXXX</one> ...... Anyone ?Thank you (7 Replies)
Discussion started by: pujansrt
7 Replies

2. Shell Programming and Scripting

Extracting Data from xml file

Hi ppl out there... Can anyone help me with the shell script to extract data from an xml file. My xml file looks like : - <servlet> <servlet-name>FrontServlet</servlet-name> <display-name>FrontServlet</display-name> ... (3 Replies)
Discussion started by: nishana
3 Replies

3. Shell Programming and Scripting

Extracting tag values from XML using perl

Hi All, I'm trying to extract the values for the 'src' and 'alt' tags within an xml file. In the files that I'm searching, the tags are always enclosed within an 'img' tag. Typically: <img src="diwiz01.gif" width="576" height="254" alt="Out-of-process and In-process COM Objects"><bookmark... (3 Replies)
Discussion started by: Steve_altius
3 Replies

4. UNIX for Dummies Questions & Answers

Extracting values from an XML file

Hello People, I have an xml file from which I need to extract the values of the parameters using UNIX shell commands. Ex : Input is like : <Name>Roger</Name> or <Address>MI</Address> I need the output as just : Roger or MI with the tags removed. Please help. (1 Reply)
Discussion started by: sushant172
1 Replies

5. Shell Programming and Scripting

Extracting field values from .csv

How can I select the bold fields from the following? "CLLI","SWREL","RPTDATE","RPTIME","TZ","RPTTYPE","RPTPD","IVALDATE","IVALSTART","IVALEND","NUMENTIDS" "tklc9010801","EAGLE5 45.0.0-64.70.1","2013-08-07","02:01:50","MST ","COMPONENT MEASUREMENTS ON... (4 Replies)
Discussion started by: leghorn
4 Replies

6. Shell Programming and Scripting

Reading XML file and extracting value

Dear All, I am reading one XML file to extract value from the particular tag:- Sample xml is below:- <KeyValuePairs> <Key>TestString</Key> <Value>Test12_Pollings</Value> </KeyValuePairs> I want to read the value for the KEY tag and there will be multiple key tags :- awk... (4 Replies)
Discussion started by: sharsour
4 Replies

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

8. Shell Programming and Scripting

Extracting the tag name from an xml file

Hi, My requirement is something like this, I have a xml file that contains some tags and nested tags, <n:tag_name1> <n:sub_tag1>val1</n:sub_tag1> <n:sub_tag2>val2</n:sub_tag2> </n:tag_name1> <n:tag_name2> <n:sub_tag1>value</n:sub_tag1> ... (6 Replies)
Discussion started by: Little
6 Replies

9. Shell Programming and Scripting

Need Help in extracting data from XML File

Hi All My input file is an XML and it has some tags and data rows at end. Starting of data rows is <rs:data> and ending of data rows is </rs:data>. Within sample data rows (2 rows) shown below, I want to extract data value after equal to sign (until space or "/" sign). So if XML data... (7 Replies)
Discussion started by: vx04
7 Replies

10. Shell Programming and Scripting

Taking key values from one file and extracting values from another file

Hi, I have two files with values in both. File1: cat 2 3 dog 4 5 elephant 6 7 camel 2 3 File2: ----+--gkf;ajf= ---+---- +----- cat -------=----+ 3 | 4 ----- dog ------++-- 5 | 9 ----++-- elephant | 5 | 7 ---++ camel ------ ++++_---- || 8 | 9 I want the final file as: cat 4... (1 Reply)
Discussion started by: npatwardhan
1 Replies
ITSTOOL(1)						      General Commands Manual							ITSTOOL(1)

NAME
itstool - convert between XML and PO using ITS SYNOPSIS
itstool [OPTIONS] [XMLFILES] itstool -m <MOFILE> [OPTIONS] [XMLFILES] DESCRIPTION
itstool extracts messages from XML files and outputs PO template files, then merges translations from MO files to create translated XML files. It determines what to translate and how to chunk it into messages using the W3C Internationalization Tag Set (ITS). To extract messages from XML files FILES and output them to OUT.pot: itstool -o OUT.pot FILES After merging with existing translations or translating strings, generate an MO file with msgfmt(1), then output translated files to the directory DIR: itstool -m OUT.mo -o DIR FILES ITS definitions are loaded from the built-in rules, rules embedded in the source XML files, files passed with the -i option, and ITS attributes in the source XML files. Later definitions take precedence. OPTIONS
Extracting -o FILE --out=FILE output PO template to the file OUT Merging -m FILE --merge=FILE merge from an MO file FILE and output XML files -l LANG --lang=LANG explicitly set the language code output to XML -o FILE --out=FILE output XML files in the directory OUT Common -i ITS --its=ITS load the ITS rules in the file ITS (can specify multiple times) AUTHOR
Shaun McCance <shaunm@gnome.org> SEE ALSO
More documentation for itstool is maintained online. For more information, see: http://itstool.org/documentation/ itstool 1.1.3 May 2011 ITSTOOL(1)
All times are GMT -4. The time now is 03:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy