Sponsored Content
Top Forums Shell Programming and Scripting Extracting the Root Element from the XML File Post 302496702 by sree_chari on Tuesday 15th of February 2011 03:21:56 AM
Old 02-15-2011
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
Code:
<?xml version="1.0" encoding="utf-8" ?> 
<TestXMLMessage>
<TestRec>
<ID>1000</ID> 
</TestRec>
</TestXMLMessage>

Wanted to extract the TestXMLMessage.

Regards,

Chari

Last edited by Franklin52; 02-15-2011 at 04:23 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extracting XML file using sed

Hello folks I want to extract data between certain tag in XML file using 'sed' <xml> ......... .......... <one>XXXXXXXXXXXXXXXXXXXX</one> ...... Anyone ?Thank you (7 Replies)
Discussion started by: pujansrt
7 Replies

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

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

5. UNIX for Dummies Questions & Answers

Extracting data from an xml file

Hello, Please can someone assist. I have the following xml file: <?xml version="1.0" encoding="utf-8" ?> - <PUTTRIGGER xmlns:xsd="http://www.test.org/2001/XMLSchema" xmlns:xsi="http://www.test.org/2001/XMLSchema-instance" APPLICATIONNUMBER="0501160" ACCOUNTNAME="Mrs S Test"... (15 Replies)
Discussion started by: Dolph
15 Replies

6. Shell Programming and Scripting

Need help in extracting data from xml file

Hello, This is my first post in here, so excuse me if I sound too noob here! I need to extract the path "/apps/mp/installedApps/V61/HRO/hrms_01698_A_qa.ear" from the below xml extract. The path will always appear with the key "binariesURL" <deployedObject... (6 Replies)
Discussion started by: abhishek2386
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. Shell Programming and Scripting

Find if XML element has a matching required element

I want to check if every <Part> element has corresponding <Description> in this sample XML. ....<Lot Of XML> <Inv lineNumber="2"> <Item> ... (4 Replies)
Discussion started by: kchinnam
4 Replies

9. Shell Programming and Scripting

Reading XML file and extracting value

Dear All, I am reading one XML file to extract value from the particular tag:- Sample xml is below:- <KeyValuePairs> <Key>TestString</Key> <Value>Test12_Pollings</Value> </KeyValuePairs> I want to read the value for the KEY tag and there will be multiple key tags :- awk... (4 Replies)
Discussion started by: sharsour
4 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::LibXML::AttributeHash(3)				User Contributed Perl Documentation			     XML::LibXML::AttributeHash(3)

NAME
XML::LibXML::AttributeHash - tie an XML::LibXML::Element to a hash to access its attributes SYNOPSIS
tie my %hash, 'XML::LibXML::AttributeHash', $element; $hash{'href'} = 'http://example.com/'; print $element->getAttribute('href') . " "; DESCRIPTION
This class allows an element's attributes to be accessed as if they were a plain old Perl hash. Attribute names become hash keys. Namespaced attributes are keyed using Clark notation. my $XLINK = 'http://www.w3.org/1999/xlink'; tie my %hash, 'XML::LibXML::AttributeHash', $element; $hash{"{$XLINK}href"} = 'http://localhost/'; print $element->getAttributeNS($XLINK, 'href') . " "; There is rarely any need to use XML::LibXML::AttributeHash directly. In general, it is possible to take advantage of XML::LibXML::Element's overloading. The example in the SYNOPSIS could have been written: $element->{'href'} = 'http://example.com/'; print $element->getAttribute('href') . " "; The tie interface allows the passing of additional arguments to XML::LibXML::AttributeHash: tie my %hash, 'XML::LibXML::AttributeHash', $element, %args; Currently only one argument is supported, the boolean "weaken" which (if true) indicates that the tied object's reference to the element should be a weak reference. This is used by XML::LibXML::Element's overloading. The "weaken" argument is ignored if you don't have a working Scalar::Util::weaken. perl v5.16.3 2013-05-13 XML::LibXML::AttributeHash(3)
All times are GMT -4. The time now is 02:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy