Get multiple values from an xml file using one of the following commands or together awk/perl/script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get multiple values from an xml file using one of the following commands or together awk/perl/script
# 1  
Old 03-17-2014
Get multiple values from an xml file using one of the following commands or together awk/perl/script

Hello,
I have a requirement to extract the value from multiple xml node and print out the values to new file to compare.
Would be done using either awk/perl or some unix script.

For example sample input file:
Code:
.....
.....
    <factories xmi:type="resources.jdbc:DataSource" xmi:id="DataSource_1368723785468" name="ds_db2_arctic_xa" jndiName="ds/db2arcticxa" description="DB2 JCC XA-capable data source using the IBM Data Server Driver for JDBC and SQLJ. IBM Data Server Driver is the next generation of the DB2 Universal JCC driver. This data source type is configurable in version 7.0 and later nodes." providerType="DB2 Using IBM JCC Driver (XA)" authMechanismPreference="BASIC_PASSWORD" authDataAlias="lxarctibc1Node01/arcticwasdb" manageCachedHandles="false" logMissingTransactionContext="true" xaRecoveryAuthAlias="lxarctibc1Node01/arcticwasdb" diagnoseConnectionUsage="false" relationalResourceAdapter="builtin_rra" statementCacheSize="50" datasourceHelperClassname="com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper">
      <propertySet xmi:id="J2EEResourcePropertySet_1368723785478">
        <resourceProperties xmi:id="J2EEResourceProperty_1368723785478" name="databaseName" type="java.lang.String" value="DWASCER2" description="This is a required property. This is an actual database name, not the locally catalogued database name. The IBM Data Server driver does not rely on information catalogued in the DB2 database directory." required="true" ignore="false" confidential="false" supportsDynamicUpdates="false"/>
        <resourceProperties xmi:id="J2EEResourceProperty_1368723785479" name="driverType" type="java.lang.Integer" value="4" description="The JDBC connectivity type of a data source. If you want to use a type 4 driver, set the value to 4. If you want to use a type 2 driver, set the value to 2. On WebSphere Application Server for Z/OS, driverType 2 uses RRS and supports 2-phase commit processing." required="true" ignore="false" confidential="false" supportsDynamicUpdates="false"/>
          .....
		  .....
		  .....
        <resourceProperties xmi:id="J2EEResourceProperty_1368723785551" name="clientRerouteAlternateServerName" type="java.lang.String" value="" description="The list of alternate server name(s) for the DB2 server.  If more than one alternate server name is specified, then the names must be separated by a comma.  For example, host1,host2." required="false" ignore="false" confidential="false" supportsDynamicUpdates="false"/>
        <resourceProperties xmi:id="J2EEResourceProperty_1368723785552" name="unbindClientRerouteListFromJndi" type="java.lang.Boolean" value="false" description="Used with testConnection only.  When set to true, clientRerouteServerListJNDIName will be unbound from JNDI name space when performing testConnection." required="false" ignore="false" confidential="false" supportsDynamicUpdates="false"/>
      </propertySet>
      <connectionPool xmi:id="ConnectionPool_1368723785494" connectionTimeout="10" maxConnections="100" minConnections="10" reapTime="58" unusedTimeout="60" agedTimeout="0" purgePolicy="EntirePool" numberOfSharedPoolPartitions="0" numberOfUnsharedPoolPartitions="0" numberOfFreePoolPartitions="0" freePoolDistributionTableSize="0" surgeThreshold="-1" surgeCreationInterval="0" testConnection="false" testConnectionInterval="0" stuckTimerTime="0" stuckTime="0" stuckThreshold="0"/>
      <mapping xmi:id="MappingModule_1368723786749" mappingConfigAlias="" authDataAlias="lxarctibc1Node01/arcticwasdb"/>
    </factories>
.....
.....
.....
 <processDefinitions xmi:type="processexec:JavaProcessDef" xmi:id="JavaProcessDef_1183122130078" workingDirectory="${USER_INSTALL_ROOT}" executableTargetKind="JAVA_CLASS" executableTarget="com.ibm.ws.runtime.WsServer">
    <execution xmi:id="ProcessExecution_1183122130078" processPriority="20" runAsUser="" runAsGroup=""/>
    <ioRedirect xmi:id="OutputRedirect_1183122130078" stdoutFilename="${ARCTIC_LOG_DIR}/native_stdout.log" stderrFilename="${ARCTIC_LOG_DIR}/native_stderr.log"/>
    <environment xmi:id="Property_1368724145382" name="IBM_HEAPDUMPDIR" value="/dmp_was_c85" required="false"/>
    <environment xmi:id="Property_1368724163596" name="IBM_JAVACOREDIR" value="/dmp_was_c85" required="false"/>
    <environment xmi:id="Property_1368724227012" name="JAVA_DUMP_OPTS" value="ONANYSIGNAL(HEAPDUMP,JAVADUMP)" required="false"/>
    <monitoringPolicy xmi:id="MonitoringPolicy_1183122130078" maximumStartupAttempts="3" pingInterval="60" pingTimeout="300" autoRestart="true" nodeRestartState="STOPPED"/>
    <jvmEntries xmi:id="JavaVirtualMachine_1183122130078" verboseModeClass="false" verboseModeGarbageCollection="true" verboseModeJNI="false" initialHeapSize="1024" maximumHeapSize="2048" runHProf="false" hprofArguments="" debugMode="false" debugArgs="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777" genericJvmArguments="-Xgc:maxScavengeBeforeGlobal=200 -Xverbosegclog:${DMP_LOG_DIR}/gc_was_c85,20,20000 -Dcom.ibm.ws.cdi.immediate.ejb.start=true -Dsibs.site=LX" executableJarFileName="" disableJIT="false">
      <systemProperties xmi:id="Property_1" name="com.ibm.security.jgss.debug" value="off" required="false"/>
      <systemProperties xmi:id="Property_2" name="com.ibm.security.krb5.Krb5Debug" value="off" required="false"/>
    </jvmEntries>
  </processDefinitions>
.....
.....

The output should look like this:
Code:
DataSource
name = ds_db2_arctic_xa    
jndiName = ds/db2arcticxa  
connectionTimeout = 10
axConnections = 100 
minConnections = 10 
reapTime = 58 
unusedTimeout = 60 
agedTimeout = 0 
purgePolicy = EntirePool  

DataSource
....
....
....

jvmEntries
initialHeapSize = 1024  
maximumHeapSize = 2048

Thanks in advance.

Last edited by Franklin52; 03-17-2014 at 10:45 AM.. Reason: Please use code tags
# 2  
Old 03-17-2014
By the way what you have tried so far ?
# 3  
Old 03-17-2014
Search by string at the beginning of the line within the file, there are several easy ways using grep / awk / perl for example grep '<jvmEntries' file.xml. It should also be easy but I'm failing to take the values ​​that are within the "..." ex. the value "1024" or "EntirePool"
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract values from xml file script

Hi, please help on this. I want extract values of xml file structure and print in determined way. <ProjectName> --> only appears once <StructList> --> is the top node <Struct> node --> could be more than 1 NameID, STX, STY, PRX, PRY --> appears only 1 time within each <Struct> node... (10 Replies)
Discussion started by: Ophiuchus
10 Replies

2. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

3. Shell Programming and Scripting

Perl script running multiple commands at once

Hi All, I have put a perl script together to go and collect some information from multiple nodes/endpoints. The script works absolutly fine however I want to make it quicker. You will see in the below that my script calls an expect script called ssh_run_cmd2.exp followed by the IP of... (7 Replies)
Discussion started by: mutley2202
7 Replies

4. Shell Programming and Scripting

Passing values to an XML file from shell script

:wall: Hi, I have an XML file with 5 tags. I need to pass values to the XML file from a shell script that will replace values in 2 of the tags. I cannot hardcode the tag values in XML and use replace command in script as the values are likely to change. Please help !!!!!!!!!!! (2 Replies)
Discussion started by: Monalisaa
2 Replies

5. Programming

help need in the perl script that create one xml file form multiple files.

Hi every one, Please excuse me if any grammatical mistakes is there. I have multiple xml files in one directory, I need to create multiple XML files into one XML file.example files like this</p> file1:bvr.xml ... (0 Replies)
Discussion started by: veerubiji
0 Replies

6. Shell Programming and Scripting

reformatting xml file, sed or awk I think (possibly perl)

I have some xml files that cannot be read using a standard parser, or I am using the wrong parser. The issues seems to be spaces in some of the tags. Here is a sample,<UgUn 2 > <Un> -0.426753 </Un> </UgUn>The parser isn't able to find the number 2, so that information is lost, etc. It seems... (16 Replies)
Discussion started by: LMHmedchem
16 Replies

7. Shell Programming and Scripting

Shell script (not Perl) to parse xml with awk

Hi, I have to make an script according to these: - I have couples of files like: xxxxxxxxxxxxx.csv xxxxxxxxxxxxx_desc.xml - every xml file has diferent fields, but keeps this format: ........ <defaultName>2011-02-25T16:43:43.582Z</defaultName> ........... (2 Replies)
Discussion started by: Pluff
2 Replies

8. Shell Programming and Scripting

Using AWK to separate data from a large XML file into multiple files

I have a 500 MB XML file from a FileMaker database export, it's formatted horribly (no line breaks at all). The node structure is basically <FMPXMLRESULT> <METADATA> <FIELD att="............." id="..."/> </METADATA> <RESULTSET FOUND="1763457"> <ROW att="....." etc="...."> ... (16 Replies)
Discussion started by: JRy
16 Replies

9. Shell Programming and Scripting

KSH Script to Get the <TAG Values> from an XML file

Hi All, I am new to Unix I need a KSH script to get the values from XML file to write to a temp file. Like the requirement is from the below TAG <MAPPING DESCRIPTION ="Test Mapping" ISVALID ="YES" NAME ="m_test_xml" OBJECTVERSION ="1" VERSIONNUMBER ="1"> I need the MAPPING DESCRIPTION... (3 Replies)
Discussion started by: perlamohan
3 Replies
Login or Register to Ask a Question