Sponsored Content
Top Forums UNIX for Advanced & Expert Users Perl XML::DOM: How to test if element exists? Post 302572207 by MacMonster on Wednesday 9th of November 2011 10:40:58 AM
Old 11-09-2011
getElementsByTagName() always return an array. You need to determine the array size instead of checking the key exists or not.

Code:
         my @node_list = $action->getElementsByTagName('Action-category');

         if (@node_list > 0)
         {
            print "Action-category defined\n";
         }
         else
         {
            print "Action-category NOT defined\n";
         }

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to parse a XML file using PERL and XML::DOm

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

Perl: How to convert xxx@dom.ain.com to domaincom

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)
Discussion started by: Juha
6 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. Programming

DOM query selected path and show as xml

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)
Discussion started by: penyu
3 Replies

7. Shell Programming and Scripting

Test if string exists

How do I use bash to test whether a string occurs more than two times in a file? (2 Replies)
Discussion started by: locoroco
2 Replies

8. AIX

Perl Module (XML:DOM) dependency

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)
Discussion started by: srivatsa86
3 Replies

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

10. Shell Programming and Scripting

If test array element multiplication

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
Dt/Action.h(file formats)												 Dt/Action.h(file formats)

NAME
Dt/Action.h -- action service definitions SYNOPSIS
#include <Dt/Action.h> DESCRIPTION
The Dt/Action.h header defines the following DtActionStatus constants: DtACTION_OK DtACTION_INVALID_ID DtACTION_INVOKED DtACTION_DONE DtACTION_CANCELED DtACTION_FAILED DtACTION_STATUS_UPDATE The header defines the following data type through typedef: typedef unsigned long DtActionInvocationID; The header defines the following callback prototypes: typedef void (*DtActionCallbackProc)(DtActionInvocationID id, XtPointer client_data, DtActionArg *args, int argCount, DtActionStatus status); typedef void (*DtDbReloadCallbackProc)(XtPointer clientData); The header defines the following as functions: void DtDbReloadNotify(DtDbReloadCallbackProc proc, XtPointer clientData); void DtDbLoad(void); Boolean DtActionExists(char *s); char *DtActionLabel(char *s); char *DtActionDescription(char *actionName); char *DtActionIcon(char *actionName); DtActionInvocationID DtActionInvoke(Widget w, char *action, DtActionFile *args, int argCount, char *termOpts, char *execHost, char *contextDir, int useIndicator, DtActionCallbackProc statusUpdateCb, XtPointer client_data); SEE ALSO
DtActionDescription(3), DtActionExists(3), DtActionIcon(3), DtActionInvoke(3), DtActionLabel(3), DtActionCallbackProc(3), DtDbLoad(3), DtD- bReloadNotify(3), dtaction(1). Dt/Action.h(file formats)
All times are GMT -4. The time now is 04:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy