Sponsored Content
Top Forums Shell Programming and Scripting How to track the opened tags in xml using perl? Post 302525303 by DGPickett on Thursday 26th of May 2011 10:13:09 AM
Old 05-26-2011
Well, usually we use the PERL sax parser modules not home brew! They call you as tags are opened and closed, so you can deal with attributes and content.

Make an array string variable I_AM_IN and a depth integer variable xml_depth to index it, and keep track of where you are. Use them in debug or error log messages, presented as: /$I_AM_IN[0]/$I_AM_IN[1] . . .
 

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. UNIX for Dummies Questions & Answers

Possible to track FTP user last login? Last and Finger don't track them.

Like the topic says, does anyone know if it is possible to check to see when an FTP only user has logged in? Because the shell is /bin/false and they are only using FTP to access the system doing a "finger" or "last" it says they have never logged in. Is there a way to see when ftp users log in... (1 Reply)
Discussion started by: LordJezo
1 Replies

3. Shell Programming and Scripting

How to keep track of counter dynamically in perl?

Hi, I have to perform the two things; a) Have to check the previous counter value in the file. b) After some processess are runned again i have to check the same counter value in the same file. Here is the file contents. #File contents of file.txt CounterValue: 0 Here is the... (2 Replies)
Discussion started by: vanitham
2 Replies

4. Shell Programming and Scripting

How to get all the xml tags in perl?

Hi, I have 2 questions: a) Does getElementsByTagName in xml takes more time? b) If it takes more time what are the other alternatives used to get the tag names? For example: <Student> <Studname>aaa</Studname> <Studno>123</Studno> </Student> This is just a sample data. The file... (2 Replies)
Discussion started by: vanitham
2 Replies

5. Shell Programming and Scripting

File exists, but cannot be opened.How to check- whether it could be opened to read when it exists

Hi #Testing for file existence if ; then echo 'SCHOOL data is available for processing' else echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING' : i wrote a script, where it begins by checking if file exists or not. If it exists, it truncates the database... (2 Replies)
Discussion started by: rxg
2 Replies

6. Shell Programming and Scripting

How to add the multiple lines of xml tags before a particular xml tag in a file

Hi All, I'm stuck with adding multiple lines(irrespective of line number) to a file before a particular xml tag. Please help me. <A>testing_Location</A> <value>LA</value> <zone>US</zone> <B>Region</B> <value>Russia</value> <zone>Washington</zone> <C>Country</C>... (0 Replies)
Discussion started by: mjavalkar
0 Replies

7. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

I've got two different files and want to compare them. File 1 : HTML Code: <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
Discussion started by: Shaishav Shah
1 Replies

8. Shell Programming and Scripting

Perl : to split the tags from xml file

I do have an xml sheet as below where I need the perl script to filter only the hyperlink tags. <cols><col min="1" max="1" width="30.5703125" customWidth="1"/><col min="2" max="2" width="7.140625" bestFit="1" customWidth="1"/> <col min="3" max="3" width="32.28515625" bestFit="1"... (3 Replies)
Discussion started by: scriptscript
3 Replies

9. Shell Programming and Scripting

Splitting xml file into several xml files using perl

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

10. UNIX for Beginners Questions & Answers

How to pull multiple XML tags from the same XML file in Shell.?

I'm searching for the names of a TV show in the XML file I've attached at the end of this post. What I'm trying to do now is pull out/list the data from each of the <SeriesName> tags throughout the document. Currently, I'm only able to get data the first instance of that XML field using the... (9 Replies)
Discussion started by: hungryd
9 Replies
lset(1T)						       Tcl Built-In Commands							  lset(1T)

__________________________________________________________________________________________________________________________________________________

NAME
lset - Change an element in a list SYNOPSIS
lset varName ?index...? newValue _________________________________________________________________ DESCRIPTION
The lset command accepts a parameter, varName, which it interprets as the name of a variable containing a Tcl list. It also accepts zero or more indices into the list. The indices may be presented either consecutively on the command line, or grouped in a Tcl list and pre- sented as a single argument. Finally, it accepts a new value for an element of varName. If no indices are presented, the command takes the form: lset varName newValue or lset varName {} newValue In this case, newValue replaces the old value of the variable varName. When presented with a single index, the lset command treats the content of the varName variable as a Tcl list. It addresses the index'th element in it (0 refers to the first element of the list). When interpreting the list, lset observes the same rules concerning braces and quotes and backslashes as the Tcl command interpreter; however, variable substitution and command substitution do not occur. The command constructs a new list in which the designated element is replaced with newValue. This new list is stored in the variable varName, and is also the return value from the lset command. If index is negative or greater than or equal to the number of elements in $varName, then an error occurs. If index has the value end, it refers to the last element in the list, and end-integer refers to the last element in the list minus the specified integer offset. If additional index arguments are supplied, then each argument is used in turn to address an element within a sublist designated by the previous indexing operation, allowing the script to alter elements in sublists. The command, lset a 1 2 newValue or lset a {1 2} newValue replaces element 2 of sublist 1 with newValue. The integer appearing in each index argument must be greater than or equal to zero. The integer appearing in each index argument must be strictly less than the length of the corresponding list. In other words, the lset command cannot change the size of a list. If an index is outside the permitted range, an error is reported. EXAMPLES
In each of these examples, the initial value of x is: set x [list [list a b c] [list d e f] [list g h i]] => {a b c} {d e f} {g h i} The indicated return value also becomes the new value of x (except in the last case, which is an error which leaves the value of x unchanged.) lset x {j k l} => j k l lset x {} {j k l} => j k l lset x 0 j => j {d e f} {g h i} lset x 2 j => {a b c} {d e f} j lset x end j => {a b c} {d e f} j lset x end-1 j => {a b c} j {g h i} lset x 2 1 j => {a b c} {d e f} {g j i} lset x {2 1} j => {a b c} {d e f} {g j i} lset x {2 3} j => list index out of range In the following examples, the initial value of x is: set x [list [list [list a b] [list c d]] [list [list e f] [list g h]]] => {{a b} {c d}} {{e f} {g h}} The indicated return value also becomes the new value of x. lset x 1 1 0 j => {{a b} {c d}} {{e f} {j h}} lset x {1 1 0} j => {{a b} {c d}} {{e f} {j h}} SEE ALSO
list(1T), lappend(1T), lindex(1T), linsert(1T), llength(1T), lsearch(1T), lsort(1T), lrange(1T), lreplace(1T) KEYWORDS
element, index, list, replace, set ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl 8.4 lset(1T)
All times are GMT -4. The time now is 01:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy