Sponsored Content
Top Forums Shell Programming and Scripting How to nodetype as "ELEMENT_NODE" using xml::libxml in perl? Post 302525328 by DGPickett on Thursday 26th of May 2011 11:20:20 AM
Old 05-26-2011
You have to interate through your JUNKS elements and for ever JUNK child element, pull it's child elements and print them if present, and print a divider. http://www.xml.com/pub/a/2001/11/14/xml-libxml.html
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

perl folder list with "..", without ".".

Hi Everyone, if my folder "foldera" inside has one file. so if i do if ($df =~ /^\./) { next; } then i will get ### filea ### if i want to have ### .. filea ### means also display the parent .., how should i modify the perl ~// in my code? Thanks ---------- Post updated... (6 Replies)
Discussion started by: jimmy_y
6 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

The system don't boot. on the screen appears following: press enter to maintenance (or type CTRL-D to continue)...I checked with format command. ... the slices "0-root","1-swap","2-backup" exist. ...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
Discussion started by: wolfgang
16 Replies

5. Shell Programming and Scripting

Perl failure with "main::$fn" used only once:" in error logs

Hi all, Can anyone guess why this is happening? I am new to Perl, so please help me to fix this error: - I have a static html file which calls the cgi-perl script. HTML Code: <html> <head> <title> Hey Dude! </title> </head> <body> <form method="POST"... (3 Replies)
Discussion started by: bashily
3 Replies

6. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

7. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
SimpleObject(3pm)					User Contributed Perl Documentation					 SimpleObject(3pm)

NAME
XML::SimpleObject - Perl extension allowing a simple object representation of a parsed XML::Parser tree. SYNOPSIS
use XML::SimpleObject; # Construct with the key/value pairs as argument; this will create its # own XML::Parser object. my $xmlobj = new XML::SimpleObject(XML => $XML, ErrorContext => 2); # ... or construct with the parsed tree as the only argument, having to # create the XML::Parser object separately. my $parser = new XML::Parser (ErrorContext => 2, Style => "Tree"); my $xmlobj = new XML::SimpleObject ($parser->parse($XML)); my $filesobj = $xmlobj->child("files")->child("file"); $filesobj->name; $filesobj->value; $filesobj->attribute("type"); %attributes = $filesobj->attributes; @children = $filesobj->children; @some_children = $filesobj->children("some"); @chilren_names = $filesobj->children_names; DESCRIPTION
This is a short and simple class allowing simple object access to a parsed XML::Parser tree, with methods for fetching children and attributes in as clean a manner as possible. My apologies for further polluting the XML:: space; this is a small and quick module, with easy and compact usage. See XML::SimpleObject::LibXML for the same interface for XML::LibXML. USAGE
$xmlobj = new XML::SimpleObject($parser->parse($XML)) $parser is an XML::Parser object created with Style "Tree": my $parser = new XML::Parser (ErrorContext => 2, Style => "Tree"); After creating $xmlobj, this object can now be used to browse the XML tree with the following methods. $xmlobj->child('NAME') This will return a new XML::SimpleObject object using the child element NAME. $xmlobj->children('NAME') Called with an argument NAME, children() will return an array of XML::SimpleObject objects of element NAME. Thus, if $xmlobj represents the top-level XML element, 'children' will return an array of all elements directly below the top-level that have the element name NAME. $xmlobj->children Called without arguments, 'children()' will return an array of XML::SimpleObject s for all children elements of $xmlobj. These are not in the order they occur in the XML document. $xmlobj->children_names This will return an array of all the names of child elements for $xmlobj. You can use this to step through all the children of a given element (see EXAMPLES). Each name will occur only once, even if multiple children exist with that name. $xmlobj->value If the element represented by $xmlobj contains any PCDATA, this method will return that text data. $xmlobj->attribute('NAME') This returns the text for an attribute NAME of the XML element represented by $xmlobj. $xmlobj->attributes This returns a hash of key/value pairs for all elements in element $xmlobj. EXAMPLES
Given this XML document: <files> <file type="symlink"> <name>/etc/dosemu.conf</name> <dest>dosemu.conf-drdos703.eval</dest> </file> <file> <name>/etc/passwd</name> <bytes>948</bytes> </file> </files> You can then interpret the tree as follows: my $parser = new XML::Parser (ErrorContext => 2, Style => "Tree"); my $xmlobj = new XML::SimpleObject ($parser->parse($XML)); print "Files: "; foreach my $element ($xmlobj->child("files")->children("file")) { print " filename: " . $element->child("name")->value . " "; if ($element->attribute("type")) { print " type: " . $element->attribute("type") . " "; } print " bytes: " . $element->child("bytes")->value . " "; } This will output: Files: filename: /etc/dosemu.conf type: symlink bytes: 20 filename: /etc/passwd bytes: 948 You can use 'children()' without arguments to step through all children of a given element: my $filesobj = $xmlobj->child("files")->child("file"); foreach my $child ($filesobj->children) { print "child: ", $child->name, ": ", $child->value, " "; } For the tree above, this will output: child: bytes: 20 child: dest: dosemu.conf-drdos703.eval child: name: /etc/dosemu.conf Using 'children_names()', you can step through all children for a given element: my $filesobj = $xmlobj->child("files"); foreach my $childname ($filesobj->children_names) { print "$childname has children: "; print join (", ", $filesobj->child($childname)->children_names), " "; } This will print: file has children: bytes, dest, name By always using 'children()', you can step through each child object, retrieving them with 'child()'. AUTHOR
Dan Brian <dbrian@brians.org> SEE ALSO
perl(1), XML::Parser. perl v5.10.1 2010-01-03 SimpleObject(3pm)
All times are GMT -4. The time now is 02:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy