02-17-2009
XML Handling in Perl
Hi there,
I'm newby in perl and XML. I can read and parse Xml with XML-Node upper XML::Parser, but how can I create XML tags and pack my individual data in it then send through socket. PLZ lead me
Thanks in Advance.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to know the way. I have got parsing down some nodes. But I was unable to get the child node perfectly. If you have code please send it. It will be very useful for me. (0 Replies)
Discussion started by: girigopal
0 Replies
2. Shell Programming and Scripting
Hi hackers,
I would like to parse the value of one XML tag (e.g. <TAG>).
Following is the script that I have written.
awk -F"" '/<TAG>/,/<\/TAG>/ {
if ( NF == 1 ) {
sub(/^*/,"", $1)
print $1
}
}
Above ascipt works fine for the following XML tag syntax. i.e. prints "Hi" ... (8 Replies)
Discussion started by: viki
8 Replies
3. Shell Programming and Scripting
Guys,
I'm doing signal handling in Perl. I'm trying to catch ^C signal inside the script.
There two scripts : one shell script and one perl script.
The shell script calls the perl script.
For e.g. shell script a.sh and perl scipt sig.pl.
Shell script a.sh looks something like this :... (6 Replies)
Discussion started by: obelix
6 Replies
4. Shell Programming and Scripting
Hi Experts,
I have a big text file, so I want read it at eof to upper bound !. after I use a fseek to go SEEK_END, is it possible to step up upperbound?
Best Regards.
Note that I'm used perl script. (2 Replies)
Discussion started by: Zaxon
2 Replies
5. Shell Programming and Scripting
Hi,
Here is my piece of code--
sub per_user_qna_detail
{
for($index=0;$index<@records;$index++)
{
if($records =~ m/^(.*)\s*Morocco.*Entering\s*Module::authenticate/)
{
printf "INSIDE per_user_qna_detail on LINE NO $index\n";
$Time_Stamp = $1;... (0 Replies)
Discussion started by: namishtiwari
0 Replies
6. Shell Programming and Scripting
Hello all,
I have created a Perl script that tries to open connections to various systems on different ports in order to see if the machines are reachable, the ports are open, etc.
There appears to be a difference between Solaris (10) and Linux (RH/Oracle and Ubuntu) in the status or error it... (4 Replies)
Discussion started by: Hollinch
4 Replies
7. Shell Programming and Scripting
Hi All,
I'm pretty new to the forum and also to UNIX. I have a requirement for which I need some help. I have a script (example.script) where I get user inputs using the read command. I would need to pass the read-fetched input to a perl command (explained below) in my script. The part which... (3 Replies)
Discussion started by: bharath.gct
3 Replies
8. Programming
$# some text
$$ some text
$@ some text
$$. some text
Mg1 some text
Mg2 some text
.
.
.
Mg10 some text
The above 10 lines are to be extracted except the lines starting from $#,$$.,... (4 Replies)
Discussion started by: baig.abdul
4 Replies
9. Shell Programming and Scripting
I have a PERL command line embedded in a UNIX script. The script doesn't handle errors coming out of this command. I'm processing large files and occassionally I run out of disk space and end up with half a file.
perl -p -e 's/\n/\r\n/g' < TR_TMP_$4 > $4
How do I handle errors coming out... (1 Reply)
Discussion started by: OTChancy
1 Replies
10. Shell Programming and Scripting
Hi Everyone,
I'm new here and I was checking this old post:
/shell-programming-and-scripting/180669-splitting-file-into-several-smaller-files-using-perl.html
(cannot paste link because of lack of points)
I need to do something like this but understand very little of perl.
I also check... (4 Replies)
Discussion started by: mcosta
4 Replies
LEARN ABOUT SUSE
xml::dom::parser
XML::DOM::Parser(3) User Contributed Perl Documentation XML::DOM::Parser(3)
NAME
XML::DOM::Parser - An XML::Parser that builds XML::DOM document structures
SYNOPSIS
use XML::DOM;
my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("file.xml");
$doc->dispose; # Avoid memory leaks - cleanup circular references
DESCRIPTION
XML::DOM::Parser extends XML::Parser
The XML::Parser module was written by Clark Cooper and is built on top of XML::Parser::Expat, which is a lower level interface to James
Clark's expat library.
XML::DOM::Parser parses XML strings or files and builds a data structure that conforms to the API of the Document Object Model as described
at http://www.w3.org/TR/REC-DOM-Level-1 <http://www.w3.org/TR/REC-DOM-Level-1>. See the XML::Parser manpage for other additional
properties of the XML::DOM::Parser class. Note that the 'Style' property should not be used (it is set internally.)
The XML::Parser NoExpand option is more or less supported, in that it will generate EntityReference objects whenever an entity reference is
encountered in character data. I'm not sure how useful this is. Any comments are welcome.
As described in the synopsis, when you create an XML::DOM::Parser object, the parse and parsefile methods create an XML::DOM::Document
object from the specified input. This Document object can then be examined, modified and written back out to a file or converted to a
string.
When using XML::DOM with XML::Parser version 2.19 and up, setting the XML::DOM::Parser option KeepCDATA to 1 will store CDATASections in
CDATASection nodes, instead of converting them to Text nodes. Subsequent CDATASection nodes will be merged into one. Let me know if this
is a problem.
Using LWP to parse URLs
The parsefile() method now also supports URLs, e.g. http://www.erols.com/enno/xsa.xml. It uses LWP to download the file and then calls
parse() on the resulting string. By default it will use a LWP::UserAgent that is created as follows:
use LWP::UserAgent;
$LWP_USER_AGENT = LWP::UserAgent->new;
$LWP_USER_AGENT->env_proxy;
Note that env_proxy reads proxy settings from environment variables, which is what I need to do to get thru our firewall. If you want to
use a different LWP::UserAgent, you can either set it globally with:
XML::DOM::Parser::set_LWP_UserAgent ($my_agent);
or, you can specify it for a specific XML::DOM::Parser by passing it to the constructor:
my $parser = new XML::DOM::Parser (LWP_UserAgent => $my_agent);
Currently, LWP is used when the filename (passed to parsefile) starts with one of the following URL schemes: http, https, ftp, wais,
gopher, or file (followed by a colon.) If I missed one, please let me know.
The LWP modules are part of libwww-perl which is available at CPAN.
perl v5.12.1 2002-07-31 XML::DOM::Parser(3)