Sponsored Content
Top Forums Shell Programming and Scripting Removing LF from specific line in XML Post 302987571 by karumudi7 on Monday 12th of December 2016 11:23:02 PM
Old 12-13-2016
Question Removing LF from specific line in XML

Hello Guys,

I have an XML file with below sample (just one data record is given below), I am getting LF characters as mentioned in below specific lines. I need to remove those. When I tried, it is removing from complete file instead of those two specific lines.

And to add one LF after one line for each xml record.

Input :

Code:

<AMS_DOC_XML_IMPORT_FILE>
<AMS_DOCUMENT DOC_CAT="ABC” DOC_TYP=“ABC” DOC_CD=“xxxx” LF (i am getting LF here)
 DOC_DEPT_CD="4" DOC_UNIT_CD="X" DOC_ID=“yyy” LF (I am getting LF here)
 DOC_VERS_NO="1" AUTO_DOC_NUM="false" DOC_IMPORT_MODE="O">LF
 <ABS_DOC_HDR AMSDataObject=“x”>LF
<DOC_CAT Attribute=“x”><![CDATA[ABS]]></DOC_CAT>LF
<DOC_TYP Attribute=“zz”><![CDATA[ABS]]></DOC_TYP>LF
<DOC_CD Attribute=“bb”><![CDATA[GAX9N]]></DOC_CD>LF

Output :
Code:
<AMS_DOC_XML_IMPORT_FILE>LF
<AMS_DOCUMENT DOC_CAT="ABC” DOC_TYP=“ABC” DOC_CD=“xxxx” LF DOC_DEPT_CD="4" DOC_UNIT_CD="X" DOC_ID=“yyy” DOC_VERS_NO="1" 
AUTO_DOC_NUM="false" DOC_IMPORT_MODE="O">LF
<ABS_DOC_HDR AMSDataObject=“x”>LF
<DOC_CAT Attribute=“x”><![CDATA[ABS]]></DOC_CAT>LF
<DOC_TYP Attribute=“zz”><![CDATA[ABS]]></DOC_TYP>LF
<DOC_CD Attribute=“bb”><![CDATA[GAX9N]]></DOC_CD>LF


Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing leading and trailing spaces of data between the tags in xml.

I am having xml document as below. <transactionid> 00 </transactionid> <tracknumber> 0 </tracknumber> <key> N/A </key> But the data contains leading and trailing spaces between the tags. Please let me know how can i remove these leading and trailing spaces between the tags.... (2 Replies)
Discussion started by: jhmr7
2 Replies

2. UNIX for Dummies Questions & Answers

Removing spaces between XML tags<XX XX> -> <XXXX>

hey guys, i have an XML like this: <documents> <document> <Object ID>100114699999</Object ID> <Object Create Date Time>2008-04-07T00:00:00</Object Create Date Time> </document> <documents> I need all my tags within the XML to not include any spaces. i.e. everything between <t a g> in... (8 Replies)
Discussion started by: sharoff
8 Replies

3. Shell Programming and Scripting

Removing specific lines

Hi I have a .conf file having many location tags like <Location /main> AuthName main AuthUserFile /ppt/gaea/passwd_main Require user admin </Location> ...... ... <Location /wonder> AuthName gaea AuthUserFile /ppt/gaea/passwd_gaea Require... (3 Replies)
Discussion started by: catgovind
3 Replies

4. Shell Programming and Scripting

Help in removing xml tags

Hi, I have a input xml file like this <postalAddress:>379 PROSPECT ST </postalAddress:> <street:>STE B </street:> <l:>TORRINGTON </l:> <st:>CT</st:> <postalCode:>067905238</postalCode:>... (5 Replies)
Discussion started by: pintoo
5 Replies

5. Shell Programming and Scripting

awk removing specific line

Hi, I have file with lines key=val. For ex(conf.file):- c=3 ef=78 b=40 ca=40 I want to remove the line with c=3, when I execute the below command it's removing both lines i.e c=3 and ca=40. Could you please correct my command. /usr/xpg4/bin/awk -v key=c 'match($0,key)... (3 Replies)
Discussion started by: axes
3 Replies

6. Shell Programming and Scripting

Using awk to read a specific line and a specific field on that line.

Say the input was as follows: Brat 20 x 1000 32rf Pour 15 p 1621 05pr Dart 10 z 1111 22xx My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour" I currently have this line but it is... (6 Replies)
Discussion started by: Bungkai
6 Replies

7. Shell Programming and Scripting

Removing unwanted tags from xml file

I have a XML file given as below: "<ProductUOMAlternativeDetails> <removetag> <UOMCode>EA</UOMCode> <numeratorForConversionToBaseUOM>1</numeratorForConversionToBaseUOM> <denominatorForConversionToBaseUOM>1</denominatorForConversionToBaseUOM> <length>0.59</length> <width>0.96</width> ... (3 Replies)
Discussion started by: vikingh
3 Replies

8. Shell Programming and Scripting

Removing last character of a specific line from a file

Hello guys, I would need to remove the last character ")" of a specific line. This can be from any line. Your help is appreciated. Below is the line. HOSTNAME=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)) Please help. (6 Replies)
Discussion started by: sang8g
6 Replies

9. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 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
YAZ_RECORD(3)								 1							     YAZ_RECORD(3)

yaz_record - Returns a record

SYNOPSIS
string yaz_record (resource $id, int $pos, string $type) DESCRIPTION
The yaz_record(3) function inspects a record in the current result set at the position specified by parameter $pos. PARAMETERS
o $id - The connection resource returned by yaz_connect(3). o $pos - The record position. Records positions in a result set are numbered 1, 2, ... $hits where $hits is the count returned by yaz_hits(3). o $type - The $type specifies the form of the returned record. Note It is the application which is responsible for actually ensuring that the records are returned from the Z39.50/SRW server in the proper format. The type given only specifies a conversion to take place on the client side (in PHP/YAZ). Besides conversion of the transfer record to a string/array, PHP/YAZ it is also possible to perform a character set conversion of the record. Especially for USMARC/MARC21 that is recommended since these are typically returned in the character set MARC-8 that is not supported by browsers, etc. To specify a conversion, add ; charset= from , to where from is the original character set of the record and to is the resulting character set (as seen by PHP). o string - The record is returned as a string for simple display. In this mode, all MARC records are converted to a line-by- line format since ISO2709 is hardly readable. XML records and SUTRS are returned in their original format. GRS-1 are returned in a (ugly) line-by-line format. This format is suitable if records are to be displayed in a quick way - for debugging - or because it is not feasible to perform proper display. o xml - The record is returned as an XML string if possible. In this mode, all MARC records are converted to MARCXML. XML records and SUTRS are returned in their original format. GRS-1 is not supported. This format is similar to $string except that MARC records are converted to MARCXML This format is suitable if records are processed by an XML parser or XSLT pro- cessor afterwards. o raw - The record is returned as a string in its original form. This type is suitable for MARC, XML and SUTRS. It does not work for GRS-1. MARC records are returned as a ISO2709 string. XML and SUTRS are returned as strings. o syntax - The syntax of the record is returned as a string, i.e. USmarc, GRS-1, XML, etc. o database - The name of database associated with record at the position is returned as a string. o array - The record is returned as an array that reflects the GRS-1 structure. This type is suitable for MARC and GRS-1. XML, SUTRS are not supported and if the actual record is XML or SUTRS an empty string will be returned. The array returned consists of a list corresponding to each leaf/internal node of GRS-1. Each list item consists a sub list with first element path and data (if data is available). The path which is a string holds a list of each tree component (of the structured GRS-1 record) from root to leaf. Each component is a tag type, tag value pair of the form ( type , value String tags nor- mally has a corresponding tag type 3. MARC can also be returned as an array (they are converted to GRS-1 internally). RETURN VALUES
Returns the record at position $pos or an empty string if no record exists at the given position. If no database record exists at the given position an empty string is returned. EXAMPLES
Example #1 Array for GRS-1 record Consider this GRS-1 record: (4,52)Robert M. Pirsig (4,70) (4,90) (2,7)Transworld Publishers, ltd. Robert M. Pirsig. Second element at root level (4,70) has a subtree with a single element (4,90). (4,90) has yet another sub tree (2,7) with data Transworld Publishers, ltd.. If this record is present at position $p, then <?php $ar = yaz_record($id, $p, "array"); print_r($ar); ?> Array ( [0] => Array ( [0] => (4,52) [1] => Robert M. Pirsig ) [1] => Array ( [0] => (4,70) ) [2] => Array ( [0] => (4,70)(4,90) ) [3] => Array ( [0] => (4,70)(4,90)(2,7) [1] => Transworld Publishers, ltd. ) ) Example #2 Working with MARCXML The following PHP snippet returns a MARC21/USMARC record as MARCXML. The original record is returned in marc-8 (unknown to most XML parsers), so we convert it to UTF-8 (which all XML parsers must support). <?php $rec = yaz_record($id, $p, "xml; charset=marc-8,utf-8"); ?> The record $rec can be processed with the Sablotron XSLT processor as follows: <?php $xslfile = 'display.xsl'; $processor = xslt_create(); $parms = array('/_xml' => $rec); $res = xslt_process($processor, 'arg:/_xml', $xslfile, NULL, $parms); xslt_free($processor); $res = preg_replace("'</?html[^>]*>'", '', $res); echo $res; ?> For PHP 5 the XSL extension must be used instead of Sablotron XSLT. PHP Documentation Group YAZ_RECORD(3)
All times are GMT -4. The time now is 08:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy