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
MB_CONVERT_KANA(3)							 1							MB_CONVERT_KANA(3)

mb_convert_kana - Convert ";kana" one from another ("zen-kaku", "han-kaku" and more)

SYNOPSIS
string mb_convert_kana (string $str, [string $option = "KV"], [string $encoding = mb_internal_encoding()]) DESCRIPTION
Performs a "han-kaku" - "zen-kaku" conversion for string$str. This function is only useful for Japanese. PARAMETERS
o $str - The string being converted. o $option - The conversion option. Specify with a combination of following options. Applicable Conversion Options +-------+---------------------------------------------------+ |Option | | | | | | | Meaning | | | | +-------+---------------------------------------------------+ | | | | r | | | | | | | Convert "zen-kaku" alphabets to "han-kaku" | | | | | | | | R | | | | | | | Convert "han-kaku" alphabets to "zen-kaku" | | | | | | | | n | | | | | | | Convert "zen-kaku" numbers to "han-kaku" | | | | | | | | N | | | | | | | Convert "han-kaku" numbers to "zen-kaku" | | | | | | | | a | | | | | | | Convert "zen-kaku" alphabets and numbers to | | | "han-kaku" | | | | | | | | A | | | | | | | Convert "han-kaku" alphabets and numbers to | | | "zen-kaku" (Characters included in "a", "A" | | | options are U+0021 - U+007E excluding U+0022, | | | U+0027, U+005C, U+007E) | | | | | | | | s | | | | | | | Convert "zen-kaku" space to "han-kaku" (U+3000 | | | -> U+0020) | | | | | | | | S | | | | | | | Convert "han-kaku" space to "zen-kaku" (U+0020 | | | -> U+3000) | | | | | | | | k | | | | | | | Convert "zen-kaku kata-kana" to "han-kaku kata- | | | kana" | | | | | | | | K | | | | | | | Convert "han-kaku kata-kana" to "zen-kaku kata- | | | kana" | | | | | | | | h | | | | | | | Convert "zen-kaku hira-gana" to "han-kaku kata- | | | kana" | | | | | | | | H | | | | | | | Convert "han-kaku kata-kana" to "zen-kaku hira- | | | gana" | | | | | | | | c | | | | | | | Convert "zen-kaku kata-kana" to "zen-kaku hira- | | | gana" | | | | | | | | C | | | | | | | Convert "zen-kaku hira-gana" to "zen-kaku kata- | | | kana" | | | | | | | | V | | | | | | | Collapse voiced sound notation and convert them | | | into a character. Use with "K","H" | | | | +-------+---------------------------------------------------+ o $encoding -The $encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used. RETURN VALUES
The converted string. EXAMPLES
Example #1 mb_convert_kana(3) example <?php /* Convert all "kana" to "zen-kaku" "kata-kana" */ $str = mb_convert_kana($str, "KVC"); /* Convert "han-kaku" "kata-kana" to "zen-kaku" "kata-kana" and "zen-kaku" alpha-numeric to "han-kaku" */ $str = mb_convert_kana($str, "KVa"); ?> PHP Documentation Group MB_CONVERT_KANA(3)
All times are GMT -4. The time now is 11:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy