Get extract text from xml file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get extract text from xml file
# 1  
Old 04-16-2013
Get extract text from xml file

Hi Collegue,

i have a file say a.xml. it has contents
Code:
<bpelFault><faultType>1</faultType><genericSystemFault xmlns=""><part name="payload"><v2:Fault xmlns:v2="https://www.unix.com/newthread.php?do=newthread&f=30[/SIZE][SIZE=3]"><v2:BusinessScopeReference><v2:BusinessIdentifier>1-MFB0QR</v2:BusinessIdentifier><v2:EnterpriseServiceName>AccountSyncIVS_BRM_2.0</v2:EnterpriseServiceName><v2:EnterpriseServiceOperationName>syncAccount</v2:EnterpriseServiceOperationName></v2:BusinessScopeReference><v2:FaultNotification><v2:ReportingDateTime>2013-04-05T09:46:31.720+11:00</v2:ReportingDateTime><v2:FaultMessage><v2:Code>CORE_SYS_GENERIC</v2:Code><v2:Text>Error from the BRM Adapter : env:Server</v2:Text><v2:ApplicationFaultData>CORE_SYS_GENERIC - Error from the BRM Adapter : env:Server</v2:ApplicationFaultData></v2:FaultMessage><v2:FaultingService><v2:systemProviderID>03</v2:systemProviderID><v2:serviceOperation>VF_EAI_OP_CUST_MAINTAIN_BILLING_PROF </v2:serviceOperation><v2:Code>1201321</v2:Code><v2:Text>FusionId: 50031: A INF application error has occurred: 1201321DeterminateError - 
FList.java:0: ErrBuf Fields:
Error=null    Loc=FM
Field=PIN_FLD_POID    Rec=0    reserved=0
Facility=0    MessageID=0    Time=10:00 AM    Version=0    Reserved2=0
Args=&lt;none>
Nested Error:
&lt;none>
DeterminateError - 
FList.java:0: ErrBuf Fields:
Error=null    Loc=FM
Field=PIN_FLD_POID    Rec=0    reserved=0
Facility=0    MessageID=0    Time=10:00 AM    Version=0    Reserved2=0
Args=&lt;none>
Nested Error:
&lt;none>
</v2:Text></v2:FaultingService></v2:FaultNotification></v2:Fault></part></genericSystemFault></bpelFault>

i need the text between <v2:Text> and </v2:Text>. that is given as below.
Code:
Error from the BRM Adapter : env:Server
FusionId: 50031: A INF application error has occurred: 1201321DeterminateError - 
FList.java:0: ErrBuf Fields:
Error=null    Loc=FM
Field=PIN_FLD_POID    Rec=0    reserved=0
Facility=0    MessageID=0    Time=10:00 AM    Version=0    Reserved2=0
Args=&lt;none>
Nested Error:
&lt;none>
DeterminateError - 
FList.java:0: ErrBuf Fields:
Error=null    Loc=FM
Field=PIN_FLD_POID    Rec=0    reserved=0
Facility=0    MessageID=0    Time=10:00 AM    Version=0    Reserved2=0
Args=&lt;none>
Nested Error:
&lt;none>

quick must be appriciated.
Thanks,
Jewel

Last edited by Corona688; 04-16-2013 at 02:51 PM..
# 2  
Old 04-16-2013
Code:
$ awk '/v2:Text>/,/\/v2:Text>/ { gsub(/\/?v2:Text>/, ""); print }' RS="<" v2text.xml

Error from the BRM Adapter : env:Server

FusionId: 50031: A INF application error has occurred: 1201321DeterminateError -
FList.java:0: ErrBuf Fields:
Error=null    Loc=FM
Field=PIN_FLD_POID    Rec=0    reserved=0
Facility=0    MessageID=0    Time=10:00 AM    Version=0    Reserved2=0
Args=&lt;none>
Nested Error:
&lt;none>
DeterminateError -
FList.java:0: ErrBuf Fields:
Error=null    Loc=FM
Field=PIN_FLD_POID    Rec=0    reserved=0
Facility=0    MessageID=0    Time=10:00 AM    Version=0    Reserved2=0
Args=&lt;none>
Nested Error:
&lt;none>

$

Use nawk on solaris.
# 3  
Old 04-16-2013
its working fine.

Great work dear..you are champ Smilie

can we do other approach plzz
# 4  
Old 04-16-2013
Quote:
It's working fine.

Great work dear..you are champ Smilie

Can we do another approach please?
I'm not likely to guess the approach you want, or I would have the first time Smilie Tell me what you want.
# 5  
Old 04-17-2013
there had been numerous posts on how to extract data from or specific data subset from a XML tree. My reply and suggestion would always be to depend on standard XML parsers where all the complexities are hidden from the user.
# 6  
Old 04-17-2013
Hi All,

the below command is working fine.
Code:
awk '/v2:Text>/,/\/v2:Text>/ { gsub(/\/?v2:Text>/, ""); print }' RS="<" v2text.xml

but i am facing issue to to get by attached file.

Thanks,
Jewel
# 7  
Old 04-17-2013
Facing what issue?

If it's working fine, what do you want?

If it's not, then in what sense is it "working fine"?

If the XML has changed, you'll need to show me which parts you want again.

Last edited by Corona688; 04-17-2013 at 03:55 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to write in other language in text/xml file by reading english text/xml file using C++?

Hello Team, I have 2 files.one contains english text and another contains Japanese. so i have to read english text and replace the text with Japanesh text in third file. Basically, I need a help to write japanese language in text/xml file.I heard wstring does this.Not sure how do i write... (2 Replies)
Discussion started by: SA_Palani
2 Replies

2. Shell Programming and Scripting

Extract a value from an xml file

I have this XML file format and all in one line: Fri Dec 23 00:14:52 2016 Logged Message:689|<?xml version="1.0" encoding="UTF-8"?><PORT_RESPONSE><HEADER><ORIGINATOR>XMG</ORIGINATOR><DESTINAT... (16 Replies)
Discussion started by: mrn6430
16 Replies

3. UNIX for Dummies Questions & Answers

Extract Element from XML file

<?xml version = '1.0' encoding =... (8 Replies)
Discussion started by: Siva SQL
8 Replies

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

5. Shell Programming and Scripting

Extract a particular xml only from an xml jar file

Hi..need help on how to extract a particular xml file only from an xml jar file... thanks! (2 Replies)
Discussion started by: qwerty000
2 Replies

6. Shell Programming and Scripting

Extract values from an XML File

Hi, I need to capture all the attributes with delete next to it. The source XML file is attached. The output should contain something like this below: Attributes = legacyExchangeDN Action = Delete Username = Hero Joker Loginid = joker09 OU =... (4 Replies)
Discussion started by: prvnrk
4 Replies

7. Shell Programming and Scripting

sed - extract text from xml file

hi, please help, i have an xml file, e.g: ... <tag> test text asdas="${abc}" xvxvbs:asdas${222}sdad asasa="${aa_bb_22}" </tag> ... i want to extract all "${...}", e.g: ${abc} ${222} ${aa_bb_22} thank you. (2 Replies)
Discussion started by: gioni
2 Replies

8. Shell Programming and Scripting

Extract XML content from a file

310439 2012-01-11 03:44:42,291 INFO PutServlet:? - Content of the Message is:="1.0" encoding="UTF-8"?><ESP_SSIA_ACC_FEED> 310440 <BATCH_ID>12345678519</BATCH_ID> 310441 <UID>3498748823</UID> 310442 <FEED_TYPE>FULL</FEED_TYPE> 310443 <MART_NAME>SSIA_DM_TRANSACTIONS</MART_NAME> 310444... (11 Replies)
Discussion started by: arukuku
11 Replies

9. Shell Programming and Scripting

extract a number within an xml file

Hi Everyone, I have an sh script that I am working on and I have run into a little snag that I am hoping someone here can assist me with. I am using wget to retrieve an xml file from thetvdb.com. This part works ok but what I need to be able to do is extract the series ID # from the xml and put... (10 Replies)
Discussion started by: tret
10 Replies

10. Shell Programming and Scripting

How to extract text from xml file

I have some xml files that got created by exporting a website from RedDot. I would like to extract the cost, course number, description, and meeting information. <?xml version="1.0" encoding="UTF-16" standalone="yes" ?> - <PAG PAG0="3AE6FCFD86D34896A82FCA3B7B76FF90" PAG3="525312"... (3 Replies)
Discussion started by: chrisf
3 Replies
Login or Register to Ask a Question