Sponsored Content
Top Forums Shell Programming and Scripting Find if XML element has a matching required element Post 302588387 by kchinnam on Sunday 8th of January 2012 10:30:46 PM
Old 01-08-2012
Ideally I want to look for corresponding <Description> tag for every <Part> tag two lines below.
when it can't find matching tag, search should end with false status.

Last edited by kchinnam; 01-08-2012 at 11:31 PM.. Reason: restating
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding a XML element and moving the file

Hi All, I am looking for a awk/shell which can find an element named REFERENCE in a XML file and check whether it is empty or not. If there is no value in the REFERENCE element then correspondingly move the file to some other folder. The Unix server is AIX version 4. Any inputs... (9 Replies)
Discussion started by: karansachdeva
9 Replies

2. Shell Programming and Scripting

Error to "find" a matching array element in a directory

Hi, I have defined an array which holds a couple of elements which are nothing but files names. I want to find the files in a directory for the matching file name(array elements) with less than 1 day old. When I am trying to execute the code (as below), it gives an error. Your help in this... (1 Reply)
Discussion started by: mkbaral
1 Replies

3. Shell Programming and Scripting

XML root element

Hi All Can someone please help me with this awk to search an element in a XML file with a particular value and then change the root element. Thanks & Regards Karan (9 Replies)
Discussion started by: karansachdeva
9 Replies

4. Shell Programming and Scripting

Extract XML Element Values

I have a rather large file with XML-style content. Each line contains one full XML entry. For example: 1:<Message><DNIS>1234</DNIS><UCID>3456</UCID><TransferGroup>XYZXYZ</TransferGroup></Message> 2:<Message><DNIS>9999</DNIS><UCID>2584</UCID><TransferGroup>ABCABC</TransferGroup></Message>... (1 Reply)
Discussion started by: sharpi03
1 Replies

5. UNIX Desktop Questions & Answers

read XML xml element with REGEXP

Hi, I would need to read an xml element from an xml file to a local variable. Please could you help me with a shell script to get so? Considering that I have a file called file.xml like below: <header> <description>This is the description</description> <content>This is the... (2 Replies)
Discussion started by: oscarmon
2 Replies

6. Shell Programming and Scripting

Extracting the Root Element from the XML File

Any help to extract the root element from an XML file will be appreciated. Example: test.xml <?xml version="1.0" encoding="utf-8" ?> <TestXMLMessage> <TestRec> <ID>1000</ID> </TestRec> </TestXMLMessage> Wanted to extract the TestXMLMessage. Regards, Chari (6 Replies)
Discussion started by: sree_chari
6 Replies

7. Shell Programming and Scripting

Need to find root element name of XML file

Given this XML: <?xml version="1.0"?> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> ... (2 Replies)
Discussion started by: ricksj
2 Replies

8. UNIX for Advanced & Expert Users

Perl XML::DOM: How to test if element exists?

Hi, I'm trying to write a script for some xml file handling, but I'm not getting too far with it. I've got the following xml content <?xml version="1.0" encoding="UTF-8"?> <Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <Operation name="OPER1"> <Action name="ACTION1">... (2 Replies)
Discussion started by: Juha
2 Replies

9. Shell Programming and Scripting

Find first n element by matching IDs

Hi All I have a problem that I am not able to resolve. Briefly, I have a file like this: ID_1 10 ID_2 15 ID_3 32 ID_4 45 ID_5 66 ID_6 79 ID_7 88This file is numerically ordered for the 2th column. And another file containing a list of IDs(just one in this example) ID_4What I... (7 Replies)
Discussion started by: giuliangiuseppe
7 Replies

10. UNIX for Dummies Questions & Answers

Extract Element from XML file

<?xml version = '1.0' encoding =... (8 Replies)
Discussion started by: Siva SQL
8 Replies
XML::Handler::XMLWriter(3)				User Contributed Perl Documentation				XML::Handler::XMLWriter(3)

NAME
XML::Handler::XMLWriter - a PerlSAX handler for writing readable XML SYNOPSIS
use XML::Parser::PerlSAX; use XML::Handler::XMLWriter; $my_handler = XML::Handler::XMLWriter->new( I<OPTIONS> ); XML::Parser::PerlSAX->new->parse(Source => { SystemId => 'REC-xml-19980210.xml' }, Handler => $my_handler); DESCRIPTION
"XML::Handler::XMLWriter" is a PerlSAX handler for writing readable XML (in contrast to Canonical XML, for example). XML::Handler::XMLWriter can be used with a parser to reformat XML, with XML::DOM or XML::Grove to write out XML, or with other PerlSAX modules that generate events. "XML::Handler::XMLWriter" is intended to be used with PerlSAX event generators and does not perform any checking itself (for example, matching start and end element events). If you want to generate XML directly from your Perl code, use the XML::Writer module. XML::Writer has an easy to use interface and performs many checks to make sure that the XML you generate is well-formed. "XML::Handler::XMLWriter" is a subclass of "XML::Handler::Subs". "XML::Handler::XMLWriter" can be further subclassed to alter it's behavior or to add element-specific handling. In the subclass, each time an element starts, a method by that name prefixed with `s_' is called with the element to be processed. Each time an element ends, a method with that name prefixed with `e_' is called. Any special characters in the element name are replaced by underscores. If there isn't a start or end method for an element, the default action is to write the start or end tag. Start and end methods can use the `"print_start_element()"' and `"print_end_element()"' methods to print start or end tags. Subclasses can call the `"print()"' method to write additional output. Subclassing XML::Handler::XMLWriter in this way is similar to XML::Parser's Stream style. XML::Handler::Subs maintains a stack of element names, `"$self-"{Names}', and a stack of element nodes, `"$self-"{Nodes}>' that can be used by subclasses. The current element is pushed on the stacks before calling an element-name start method and popped off the stacks after calling the element-name end method. See XML::Handler::Subs for additional methods. In addition to the standard PerlSAX handler methods (see PerlSAX for descriptions), XML::Handler::XMLWriter supports the following methods: new( OPTIONS ) Creates and returns a new instance of XML::Handler::XMLWriter with the given OPTIONS. Options may be changed at any time by modifying them directly in the hash returned. OPTIONS can be a list of key, value pairs or a hash. The following OPTIONS are supported: Output An IO::Handle or one of it's subclasses (such as IO::File), if this parameter is not present and the AsString option is not used, the module will write to standard output. AsString Return the generated XML as a string from the `"parse()"' method of the PerlSAX event generator. Newlines A true or false value; if this parameter is present and its value is true, then the module will insert an extra newline before the closing delimiter of start, end, and empty tags to guarantee that the document does not end up as a single, long line. If the paramter is not present, the module will not insert the newlines. IsSGML A true or false value; if this parameter is present and its value is true, then the module will generate SGML rather than XML. print_start_element($element) Print a start tag for `$element'. This is the default action for the PerlSAX `"start_element()"' handler, but subclasses may use this if they define a start method for an element. print_end_element($element) Prints an end tag for `$element'. This is the default action for the PerlSAX `"end_element()"' handler, but subclasses may use this if they define a start method for an element. print($output) Write `$output' to Output and/or append it to the string to be returned. Subclasses may use this to write additional output. TODO
o An Elements option that provides finer control over newlines than the Newlines option, where you can choose before and after newline for element start and end tags. Inspired by the Python XMLWriter. o Support Doctype and XML declarations. AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us This module is partially derived from XML::Writer by David Megginson. SEE ALSO
perl(1), PerlSAX.pod(3) perl v5.16.3 2003-10-21 XML::Handler::XMLWriter(3)
All times are GMT -4. The time now is 12:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy