Sponsored Content
Top Forums Shell Programming and Scripting Find string in XML file, copy contents of section Post 302614199 by jrfiol on Wednesday 28th of March 2012 10:28:10 AM
Old 03-28-2012
Find string in XML file, copy contents of section

I am new, really new to bash scripts.

I want to search an XML file for a certain string, say "1234567890"

Once found, I want to copy the entire contents from the previous instance of the string "Entity" to the next instance of "/Entity" to a txt file.

And then continue searching for the string in the same file.

Thank you for any guidance,

jrfiol

Last edited by jrfiol; 03-28-2012 at 11:29 AM.. Reason: read it and felt it needed more
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

find and copy string in a file

Hello there I need to find a string in an file, and then copy to a new file from the previous 6 lines to 41 lines after the string. So, what i need to do , and just don't know how, is to find the string and copy 48 lines where the string would be in the 7th line. I don't know if i can do it with... (10 Replies)
Discussion started by: vascobrito
10 Replies

2. UNIX for Dummies Questions & Answers

help find a section line of a file

hi, I have a 20 line file. I need a command which will brinf back a specific line based upon the line number I enter. e.g. the file looks like this and is called file1 jim is a man john is a woman james is a man wendy is a woman lesley is a woman i want a command that will... (4 Replies)
Discussion started by: sureshy
4 Replies

3. Shell Programming and Scripting

Copy selected contents from file

I want to capture contents of a file between 2 strings into another file for eg all lines in between the keywords "start log" and "end log" should be copied into another file (4 Replies)
Discussion started by: misenkiser
4 Replies

4. Shell Programming and Scripting

Copy contents of a directory only if a file exists

I'm looking to write a script that will check the contents of a directory, and if any files exist in that directory copy them to a temporary folder. The target files are only resident for a few seconds, so I think the script needs to be running constantly. Any pointers would be really... (3 Replies)
Discussion started by: danceofillusion
3 Replies

5. Shell Programming and Scripting

copy the contents between two keywords to a new file.

Hi All, I want to edit my gate level netlists by searching for the content between two patterns eg: ff1 \test/a0 ( .CLK(\test/ClkInt0_acb_00x1 ),.D(\test/Rakicc ), .QB(\test/X ), .VDD(1'b1), .VSS(1'b0)); ff1 \test/a1 ( .CLK(\test/medis0_acb_00x1 ),.D(\test/hedwc ), .QB(\test/X ),... (6 Replies)
Discussion started by: naveen@
6 Replies

6. Shell Programming and Scripting

Need help to copy contents of a file

Hi, I am stuck up with a problem of copying the contents of a directory where one of the folder name is changed daily. Problem: I have the folder structure as: RefWorlds2/LINGCC4_X64/odsdev/odessy/UTI/621GA_build_xxx/.../.. In the above path the build number (xxx) will be changed... (3 Replies)
Discussion started by: SathaKarni
3 Replies

7. Shell Programming and Scripting

sed - String substitution within specified section in ini type file

Hello. I am trying to modify a config file which is in windows *.ini type file. I have found a piece of code here :linux - Edit file in unix using SED - Stack Overflow As I can't make it doing the job , I am trying to find a solution step by step. here a modified sample file : my_sample.ini... (1 Reply)
Discussion started by: jcdole
1 Replies

8. Shell Programming and Scripting

Copy contents of one file to another

I need to write a script (in bash) that copies the content of the first file in each folder of a directory to the second file in the same folder. I tried this and it didn't work - it just came back with errors and I'm not sure how to fix it. Help is very much appreciated! for mpdir in... (4 Replies)
Discussion started by: LeftoverStew
4 Replies

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

10. UNIX for Beginners Questions & Answers

Copy last 30 minutes' contents from a log file

Hi Guys, I am writing a bash script to capture the last 30 minutes's contents from log file to a new file. This job is a scheduled job and will run every 30 minutes. The log file is db2diag.log in DB2. I am having difficulties copying the last 30 minutes's contents. Can someone please help me.... (4 Replies)
Discussion started by: naveed
4 Replies
XMLREADER(3)								 1							      XMLREADER(3)

The XMLReader class

INTRODUCTION
The XMLReader extension is an XML Pull parser. The reader acts as a cursor going forward on the document stream and stopping at each node on the way. CLASS SYNOPSIS
XMLReader XMLReader Constants o const int$XMLReader::NONE0 o const int$XMLReader::ELEMENT1 o const int$XMLReader::ATTRIBUTE2 o const int$XMLReader::TEXT3 o const int$XMLReader::CDATA4 o const int$XMLReader::ENTITY_REF5 o const int$XMLReader::ENTITY6 o const int$XMLReader::PI7 o const int$XMLReader::COMMENT8 o const int$XMLReader::DOC9 o const int$XMLReader::DOC_TYPE10 o const int$XMLReader::DOC_FRAGMENT11 o const int$XMLReader::NOTATION12 o const int$XMLReader::WHITESPACE13 o const int$XMLReader::SIGNIFICANT_WHITESPACE14 o const int$XMLReader::END_ELEMENT15 o const int$XMLReader::END_ENTITY16 o const int$XMLReader::XML_DECLARATION17 o const int$XMLReader::LOADDTD1 o const int$XMLReader::DEFAULTATTRS2 o const int$XMLReader::VALIDATE3 o const int$XMLReader::SUBST_ENTITIES4 Properties o publicreadonly int$attributeCount o publicreadonly string$baseURI o publicreadonly int$depth o publicreadonly bool$hasAttributes o publicreadonly bool$hasValue o publicreadonly bool$isDefault o publicreadonly bool$isEmptyElement o publicreadonly string$localName o publicreadonly string$name o publicreadonly string$namespaceURI o publicreadonly int$nodeType o publicreadonly string$prefix o publicreadonly string$value o publicreadonly string$xmlLang Methods o public bool XMLReader::close (void ) o public DOMNode XMLReader::expand ([DOMNode $basenode]) o public string XMLReader::getAttribute (string $name) o public string XMLReader::getAttributeNo (int $index) o public string XMLReader::getAttributeNs (string $localName, string $namespaceURI) o public bool XMLReader::getParserProperty (int $property) o public bool XMLReader::isValid (void ) o public bool XMLReader::lookupNamespace (string $prefix) o public bool XMLReader::moveToAttribute (string $name) o public bool XMLReader::moveToAttributeNo (int $index) o public bool XMLReader::moveToAttributeNs (string $localName, string $namespaceURI) o public bool XMLReader::moveToElement (void ) o public bool XMLReader::moveToFirstAttribute (void ) o public bool XMLReader::moveToNextAttribute (void ) o public bool XMLReader::next ([string $localname]) o public bool XMLReader::open (string $URI, [string $encoding], [int $options]) o public bool XMLReader::read (void ) o public string XMLReader::readInnerXML (void ) o public string XMLReader::readOuterXML (void ) o public string XMLReader::readString (void ) o public bool XMLReader::setParserProperty (int $property, bool $value) o public bool XMLReader::setRelaxNGSchema (string $filename) o public bool XMLReader::setRelaxNGSchemaSource (string $source) o public bool XMLReader::setSchema (string $filename) o public bool XMLReader::xml (string $source, [string $encoding], [int $options]) PROPERTIES
o $attributeCount - The number of attributes on the node o $baseURI -The base URI of the node o $depth -Depth of the node in the tree, starting at 0 o $hasAttributes -Indicates if node has attributes o $hasValue -Indicates if node has a text value o $isDefault -Indicates if attribute is defaulted from DTD o $isEmptyElement -Indicates if node is an empty element tag o $localName -The local name of the node o $name -The qualified name of the node o $namespaceURI -The URI of the namespace associated with the node o $nodeType -The node type for the node o $prefix -The prefix of the namespace associated with the node o $value -The text value of the node o $xmlLang -The xml:lang scope which the node resides PREDEFINED CONSTANTS
XMLREADER NODE TYPES
o XMLReader::NONE -No node type o XMLReader::ELEMENT -Start element o XMLReader::ATTRIBUTE -Attribute node o XMLReader::TEXT -Text node o XMLReader::CDATA -CDATA node o XMLReader::ENTITY_REF -Entity Reference node o XMLReader::ENTITY -Entity Declaration node o XMLReader::PI -Processing Instruction node o XMLReader::COMMENT -Comment node o XMLReader::DOC -Document node o XMLReader::DOC_TYPE -Document Type node o XMLReader::DOC_FRAGMENT -Document Fragment node o XMLReader::NOTATION -Notation node o XMLReader::WHITESPACE -Whitespace node o XMLReader::SIGNIFICANT_WHITESPACE -Significant Whitespace node o XMLReader::END_ELEMENT -End Element o XMLReader::END_ENTITY -End Entity o XMLReader::XML_DECLARATION -XML Declaration node XMLREADER PARSER OPTIONS
o XMLReader::LOADDTD -Load DTD but do not validate o XMLReader::DEFAULTATTRS -Load DTD and default attributes but do not validate o XMLReader::VALIDATE -Load DTD and validate while parsing o XMLReader::SUBST_ENTITIES -Substitute entities and expand references PHP Documentation Group XMLREADER(3)
All times are GMT -4. The time now is 04:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy