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
This is just a small piece of the actual file that can be thousands of lines.
Some "Actions" can have "Action-category" but some do not, and I would like to be able to do different processing based on that. I am however unable to test if this element exists.
My code is as follows:
and it results in to the following output:
So, it says the "action-category" is defined, even though it is not?
Would anyone have any idea why or how to fix this?
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)
Hi,
Is there a way to convert xxx@dom.ain.com to domaincom, so to remove everything before and including @ and then to remove the dot from the rest of the line?
I know I can do:
$str = "xxx\@dom.ain.com";
print "String before: $str\n";
$str =~ s/.*?@//;
$str =~ s/\.//g;
print... (6 Replies)
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)
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)
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)
First, I am sorry if this question not this room scope,
I have a XML file :
file: book.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
... (3 Replies)
Hi All,
I am facing dependency on AIX :confused:.I am trying to run an script which requires PERL MODULE (XML::DOM) to be installed. Please find the attached file which shows the error i am getting (cant locate XML/DOM.pm in @INC).
Please let me know how to install PERL MODULE (XML::DOM)
... (3 Replies)
I want to check if every <Part> element has corresponding <Description> in this sample XML.
....<Lot Of XML>
<Inv lineNumber="2">
<Item>
... (4 Replies)
Ya, I know, who in this day and age is mirroring rootvg...?
But yes, my shop does and I need to script checking for it.
I also know I could just inverse the the logic and call the LV mirrored
if the LPs and PPs were not equal. But I want to do the math in the if test
and also know I could... (5 Replies)
Discussion started by: gtsonoma
5 Replies
LEARN ABOUT DEBIAN
xml::dom::valparser
XML::DOM::ValParser(3pm) User Contributed Perl Documentation XML::DOM::ValParser(3pm)NAME
XML::DOM::ValParser - an XML::DOM::Parser that validates at parse time
SYNOPSIS
use XML::DOM::ValParser;
my %expat_options = (KeepCDATA => 1,
Handlers => [ Unparsed => &my_Unparsed_handler ]);
my $parser = new XML::DOM::ValParser (%expat_options);
eval {
local $XML::Checker::FAIL = &my_fail;
my $doc = $parser->parsefile ("fail.xml");
... XML::DOM::Document was created sucessfully ...
};
if ($@) {
# Either XML::Parser (expat) threw an exception or my_fail() died.
... your error handling code here ...
# Note that the XML::DOM::Document is automatically disposed off and
# will be garbage collected
}
# Throws an exception (with die) when an error is encountered, this
# will stop the parsing process.
# Don't die if a warning or info message is encountered, just print a message.
sub my_fail {
my $code = shift;
die XML::Checker::error_string ($code, @_) if $code < 200;
XML::Checker::print_error ($code, @_);
}
DESCRIPTION
Use XML::DOM::ValParser wherever you would use XML::DOM::Parser and your XML will be checked using XML::Checker at parse time.
See XML::DOM for details on XML::DOM::Parser options. See XML::Checker for details on setting the fail handler (my_fail.)
The following handlers are currently supported, just like XML::DOM::Parser: Init, Final, Char, Start, End, Default, Doctype, CdataStart,
CdataEnd, XMLDecl, Entity, Notation, Proc, Default, Comment, Attlist, Element, Unparsed.
XML ::DOM::ValParser
XML::DOM::ValParser extends from XML::Checker::Parser. It creates an XML::Checker object and routes all event handlers through the checker,
before processing the events to create the XML::DOM::Document.
Just like XML::Checker::Parser, the checker object can be retrieved with the getChecker() method and can be reused later on (provided that
the DOCTYPE section of the XML::DOM::Document did not change in the mean time.)
You can control which errors are fatal (and therefore should stop creation of the XML::DOM::Document) by filtering the appropriate error
codes in the global $XML::Checker::FAIL handler (see "ERROR_HANDLING" in XML::Checker) and calling die or croak appropriately.
Just like XML::Checker::Parser, XML::DOM::ValParser supports the SkipExternalDTD and SkipInsignifWS options. See XML::Checker::Parser for
details.
AUTHOR
Enno Derksen is the original author.
Send bug reports, hints, tips, suggestions to T.J. Mather at <tjmather@tjmather.com>.
SEE ALSO
XML::DOM, XML::Checker ("SEE_ALSO" in XML::Checker)
perl v5.10.0 2001-08-26 XML::DOM::ValParser(3pm)