Sponsored Content
Top Forums Shell Programming and Scripting Help with XML tag value extraction based on matching condition Post 303000576 by RavinderSingh13 on Friday 14th of July 2017 01:55:37 PM
Old 07-14-2017
Hello paul1234,

Could you please try following and let me know if this helps you.
Solution 1st: Looking for string <_LocalId> with making field separator -F[[><]' as follows.
Code:
awk -F'[><]' '/<_LocalId>/{print $3}'   Input_file

Solution 2nd: Looking for string <_LocalId> and then substituting everything till > and then globally substituting > and <.* too and then printing the line.
Code:
awk '/<_LocalId>/{sub(/.[^>]*/,"");gsub(/>|<.*/,"");print}'   Input_file

Thanks,
R. Singh

Last edited by RavinderSingh13; 07-14-2017 at 03:01 PM..
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl regexp: matching the parent xml tag

Hi folks. I would like to remove the full parent (outer) xml tag from a file given a matching child (inner) tag, in a bash shell. To be more specific, this is what I have so far: $ cat myFile.xml <Sometag></Sometag> <Outer> <Inner>1</Inner> </Outer> <Outer> <stuff>alot</stuff> ... (3 Replies)
Discussion started by: BatManWSL
3 Replies

2. Shell Programming and Scripting

Remove lines from XML based on condition

Hi, I need to remove some lines from an XML file is the value within a tag is empty. Imagine this scenario, <acd><acdID>2</acdID><logon></logon></acd> <acd><acdID></acdID><logon></logon></acd> <acd><acdID></acdID><logon></logon></acd> <acd><acdID></acdID><logon></logon></acd> I... (3 Replies)
Discussion started by: giles.cardew
3 Replies

3. Shell Programming and Scripting

extract xml tag based on condition

Hi All, I have a large xml file of invoices. The file looks like below: <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>... (9 Replies)
Discussion started by: angshuman
9 Replies

4. Shell Programming and Scripting

Check the value in xml based on condition

Hi, I have a log file having n number of xml's like the one below. <uOStatus xmlns:env="http://abc.org/def/ghi/"... (3 Replies)
Discussion started by: Neethu
3 Replies

5. Shell Programming and Scripting

Convert tag based lines to xml format

Hi All, Can some one help me to convert this line of code to xml format. Thanks in advance, preethy. input: ... (2 Replies)
Discussion started by: preethy
2 Replies

6. Shell Programming and Scripting

Multi line extraction based on condition

Hi I have some data in a file as below ****************************** Class 1A Students absent are : 1. ABC 2. CDE 3. CPE ****************************** Class 2A Students absent are : ****************************** Class 3A Students absent are : (6 Replies)
Discussion started by: reldb
6 Replies

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

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

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

10. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies
XmStringSegmentCreate(library call)									       XmStringSegmentCreate(library call)

NAME
XmStringSegmentCreate -- A compound string function that creates a compound string SYNOPSIS
#include <Xm/Xm.h> XmString XmStringSegmentCreate( char * text, XmStringTag tag, XmStringDirection direction, Boolean separator); DESCRIPTION
This function is obsolete and exists for compatibility with previous releases. It can be replaced by using a combination of XmStringCompo- nentCreate and XmStringConcat. XmStringSegmentCreate is a high-level function that assembles a compound string consisting of a font list element tag, a direction component, a text component, and an optional separator component. The function allocates space for the returned compound string. The application is responsible for managing the allocated space. The application can recover the allocated space by calling XmStringFree. text Specifies a NULL-terminated string to be used as the text component of the compound string. tag Specifies the tag component to be associated with the text. The value XmFONTLIST_DEFAULT_TAG is for compatibility with previous releases. direction Specifies the direction of the text. separator A value of False means the compound string does not have a separator at the end. A value of True, means a separator immediately follows the text component. RETURN
Returns a new compound string. RELATED
XmStringCreate(3). XmStringSegmentCreate(library call)
All times are GMT -4. The time now is 06:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy