Sponsored Content
Top Forums Shell Programming and Scripting extract xml tag based on condition Post 302488106 by angshuman on Saturday 15th of January 2011 03:53:16 AM
Old 01-15-2011
extract xml tag based on condition

Hi All,

I have a large xml file of invoices. The file looks like below:
Code:
<INVOICES>
<INVOICE>
<NAME>Customer A</NAME>
<INVOICE_NO>1234</INVOICE_NO>
</INVOICE>
<INVOICE>
<NAME>Customer A</NAME>
<INVOICE_NO>2345</INVOICE_NO>
</INVOICE>
<INVOICE>
<NAME>Customer A</NAME>
<INVOICE_NO>3456</INVOICE_NO>
</INVOICE>
<INVOICE>
<NAME>Customer A</NAME>
<INVOICE_NO>5678</INVOICE_NO>
</INVOICE>
</INVOICES>

I need to extract all the <INVOICE>...........</INVOICE> provided the value of INVOICE_NO = 2345 and 5678.

I searched the forum and found how to extract values between xml tag. But this is a different scenario.

Your help is highly appreciated.

Thanks
Angshuman

Last edited by Scott; 01-15-2011 at 10:01 AM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract value inside <text> tag for a particular condition.

Hi All! I have obtained following output from a tool "pdftohtml" :: So, my input is as under: <text top="246" left="160" width="84" height="16" font="3">Business purpose</text> <text top="260" left="506" width="220" height="16" font="3">giving the right information and new insights... (3 Replies)
Discussion started by: parshant_bvcoe
3 Replies

2. UNIX for Dummies Questions & Answers

Unable to extract a tag from a very long XML message

Hi I have a log file which contain XML message. I want to extract the value between the tag : <businessEventId>13201330</businessEventId> i.e., 13201330. I tried the following commands but as the message is very long, unable to do it. Attached is the log file. Please provide inputs. --... (3 Replies)
Discussion started by: Sapna_Sai
3 Replies

3. Shell Programming and Scripting

how to extract the info in the tag from a xml file

Hi All, Do anyone of you have any idea how to extract each<info> tag to each different file. I have 1000 raw files, which come in every 15 mins.( I am using bash) I have tried my script as below, but it took hours to finish, which is inefficiency. perl -n -e '/^<info>/ and open FH,">file".$n++;... (2 Replies)
Discussion started by: natalie23
2 Replies

4. Shell Programming and Scripting

Extract multiple xml tag value into CSV format

Hi All, Need your assistance on another xml tag related issue. I have a xml file as below: <INVOICES> <INVOICE> <BILL> <BILL_NO>1234</BILL_NO> <BILL_DATE>01 JAN 2011</BILL_DATE> </BILL> <NAMEINFO> <NAME>ABC</NAME> </NAMEINFO> </INVOICE> <INVOICE> <BILL> <BILL_NO>5678</BILL_NO>... (12 Replies)
Discussion started by: angshuman
12 Replies

5. Shell Programming and Scripting

Extract TAG name and XPATH from XML file via shellscript

Hi, Here is a sample xml file and expected output. I need to extract the element/tag name (not value) and xpath (sample output.txt). But the main problem is I put here one simple xml file where I can clearly see the number of elements, but in real time I have a xml file which have over 500... (18 Replies)
Discussion started by: BithunC
18 Replies

6. Shell Programming and Scripting

Extract XML tag value from file

Hello, Hope you are doing fine. I have an log file which looks like as follows: Some junk text1 Date: Thu Mar 15 13:38:46 CDT 2012 DATA SENT SUCCESSFULL: Some jun text 2 Date: Thu Mar 15 13:38:46 CDT 2012 DATA SENT SUCCESSFULL: ... (3 Replies)
Discussion started by: srattani
3 Replies

7. Shell Programming and Scripting

Help with XML tag value extraction based on matching condition

sample xml file part <DocumentMinorVersion>0</DocumentMinorVersion> <DocumentVersion>1</DocumentVersion> <EffectiveDate>2017-05-30T00:00:00Z</EffectiveDate> <FollowOnFrom> <ContractRequest _LoadId="export_AJ6iAFoh6g0rE9"> <_LocalId>CRW2218451</_LocalId> ... (4 Replies)
Discussion started by: paul1234
4 Replies

8. Shell Programming and Scripting

Help with XML tag value extraction based on condition

sample xml file part <?xml version="1.0" encoding="UTF-8"?><ContractWorkspace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" _LoadId="export_AJ6iAFmh+pQHq1" xsi:noNamespaceSchemaLocation="ContractWorkspace.xsd"> <_LocalId>CW2218471</_LocalId> <Active>true</Active> ... (3 Replies)
Discussion started by: paul1234
3 Replies

9. Shell Programming and Scripting

Help with tag value extraction from xml file based on a matching condition

Hi , I have a situation where I need to search an xml file for the presence of a tag <FollowOnFrom> and also , presence of partial part of the following tag <ContractRequest _LoadId and if these 2 exist ,then extract the value from the following tag <_LocalId> which is "CW2094139". There... (2 Replies)
Discussion started by: paul1234
2 Replies

10. UNIX for Beginners Questions & Answers

Replacing tag based on condition

Hi All, I am having a file like below. The file will having information about the records.If you see the file the file is header and data. For example it have 1 men tag and the tag id will be come after headers. The change is I want to convert All pets tag from P to X. I did a sed like below... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies
Vend::UserDB(3pm)					User Contributed Perl Documentation					 Vend::UserDB(3pm)

NAME
UserDB.pm -- Interchange User Database Functions SYNOPSIS
userdb $function, %options DESCRIPTION
The Interchange user database saves information for users, including shipping, billing, and preference information. It allows the user to return to a previous session without the requirement for a "cookie" or other persistent session information. It is object-oriented and called via the [userdb] usertag, which calls the userdb subroutine. It restores and manipulates the form values normally stored in the user session values -- the ones set in forms and read through the "[value variable]" tags. A special function allows saving of shopping cart contents. The preference, billing, and shipping information is keyed so that different sets of information may be saved, providing and "address_book" function that can save more than one shipping and/or billing address. The set to restore is selected by the form values "s_nickname", "b_nickname", and "p_nickname". METHODS
User login: $obj->login(); # Form values are # mv_username, mv_password Create account: $obj->new_account(); # Form values are # mv_username, mv_password, mv_verify Change password: $obj->change_pass(); # Form values are # mv_username, mv_password_old, mv_password, mv_verify(new) Get, set user information: $obj->get_values(); $obj->set_values(); $obj->clear_values(); Save, restore filed user information: $obj->get_shipping(); $obj->set_shipping(); $obj->get_billing(); $obj->set_billing(); $obj->get_preferences(); $obj->set_preferences(); $obj->get_cart(); $obj->set_cart(); Shipping Address Book The shipping address book saves information relevant to shipping the order. In its simplest form, this can be the only address book needed. By default these form values are included: s_nickname name address city state zip country phone_day mv_shipmode The values are saved with the $obj->set_shipping() method and restored with $obj->get_shipping. A list of the keys available is kept in the form value "address_book", suitable for iteration in an HTML select box or in a set of links. Accounts Book The accounts book saves information relevant to billing the order. By default these form values are included: b_nickname b_name b_address b_city b_state b_zip b_country b_phone mv_credit_card_type mv_credit_card_exp_month mv_credit_card_exp_year mv_credit_card_reference The values are saved with the $obj->set_billing() method and restored with $obj->get_billing. A list of the keys available is kept in the form value "accounts", suitable for iteration in an HTML select box or in a set of links. Preferences Preferences are miscellaneous session information. They include by default the fields "email", "fax", "phone_night", and "fax_order". The field "p_nickname" acts as a key to select the preference set. Locations There are several database locations that have special purposes. These fields are not saved as user values. USERNAME default: username The username or key field of the database table. BILLING default: accounts Billing address hash field. SHIPPING default: address_book Shipping address hash field. PREFERENCES default: preferences Miscellaneous information hash field. FEEDBACK default: feedback Customer feedback hash field. PRICING default: price_level Customer pricing level marker. CARTS default: carts Saved carts hash field. PASSWORD default: password Customer password info. If "crypt" is set, may be encrypted. LAST default: mod_time Last login time EXPIRATION default: expiration Expiration of account. OUTBOARD_KEY default: (none) Key information for linking to another table of address or other info. GROUPS default: groups Groups they should be logged into. SUPER default: super Whether they are a superuser (admin). ACL default: acl FILE_ACL default: file_acl DB_ACL default: db_acl Location of access control information. CREATED_DATE_ISO default: (none) CREATED_DATE_UNIX default: (none) UPDATED_DATE_ISO default: (none) UPDATED_DATE_UNIX default: (none) Date fields. MERGED_USER default: (none) The user id of another account this was merged into. If present, and data (should be a valid user id) is present in the field, the user will be logged as that username. perl v5.14.2 2011-04-22 Vend::UserDB(3pm)
All times are GMT -4. The time now is 06:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy