Sponsored Content
Top Forums Shell Programming and Scripting Extract values from xml file script Post 303019589 by Chubler_XL on Monday 2nd of July 2018 04:28:40 PM
Old 07-02-2018
How about this:

Code:
awk -F"<|>" '
BEGIN{print "ProjectName|NameID|STX-STY|PRX-PRY|OD-ODF|ODRangeStart|ODRangeStop"}
/ProjectName/{printf "%s",$3}
/<.StructData>/{
    for(i=1; i<=rngln; i++) {
       printf "|%s|%s|%s|%s|%s|%s\n",\
          id,stx?stx"-"sty:"",\
          prx?prx"-"pry:"",\
          od[i]?od[i]"-"odf[i]:"",\
          rngStart[i],rngStop[i]
       delete od[i]
       delete odf[i]
       delete rngStart[i]
       delete rngStop[i]
       id=stx=sty=prx=pry=""
    }
    rngln=0
}
/NameID/{id=$3}
/<STX>/{stx=$3}
/<STY>/{sty=$3}
/<PRX>/{prx=$3}
/<PRY>/{pry=$3}
/<PR_Ranges>/ {PRActive=1}
!PRActive { next }
/<.PR_Ranges>/ {PRActive=0}
/<OD>/ {od[++rngln]=$3}
/ODF>/{odf[rngln]=$3}
/ODRangeStart/{rngStart[rngln]=$3}
/ODRangeStop/{rngStop[rngln]=$3}
' infile2

This User Gave Thanks to Chubler_XL For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with shell script to extract data from XML file

Hello Scripting Gurus, I need help with extracting data from the XML file using shell script. The data is in a large XML and I need to extract the id values of all completedworkflows. Here is a sample of it. Input and output data is also in the attached text files. <wfregistry>... (5 Replies)
Discussion started by: yajaykumar
5 Replies

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

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

4. Shell Programming and Scripting

Perl script to extract 'ID' From XML File

File1.xml <?xml version.........> - <abcd:abcd_list version="1" www.john_uncle's_server.com" xmlns: - <device id="100"> <firmware>12.4(3d)</firmware> <location id="500">Sitting Room</location> </device> - <device id="101"> <firmware>12.4(3d)</firmware> <location id="501">Class... (1 Reply)
Discussion started by: sureshcisco
1 Replies

5. Shell Programming and Scripting

Extract values from an XML File

Hi, I need to capture all the attributes with delete next to it. The source XML file is attached. The output should contain something like this below: Attributes = legacyExchangeDN Action = Delete Username = Hero Joker Loginid = joker09 OU =... (4 Replies)
Discussion started by: prvnrk
4 Replies

6. Shell Programming and Scripting

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: ..... ..... <factories xmi:type="resources.jdbc:DataSource"... (2 Replies)
Discussion started by: slbmind
2 Replies

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

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

9. Shell Programming and Scripting

How to extract xml attribute values using awk inline.?

I am trying to extract specific XML attribute values for search pattern <factories.*baseQueueName' from resources.xml. my scripts works ok,, but to extract 3 values this code does echo $line three times, it could be 'n' times. How can I use awk to extract matching pattern values in-line or... (11 Replies)
Discussion started by: kchinnam
11 Replies
mdoc(1) 						      General Commands Manual							   mdoc(1)

NAME
mdoc - Mono documentation management tool SYNOPSIS
mdoc command [options] [args] OVERVIEW
mdoc is an assembly-based documentation management system. mdoc permits creating and updating documentation stubs based on the contents of an assembly. It does not rely on documentation found within the source code. The advantages are: * Code readability. Good documentation is frequently (a) verbose, and (b) filled with examples. (For comparison, compare Microsoft .NET Framework documentation, which is often a page or more of docs for each member, to JavaDoc documentation, which can often be a sentence for each member.) Inserting good documentation into the source code can frequently bloat the source file, as the documentation can be longer than the actual method that is being documented. * Localization. In-source documentation formats (such as csc /doc) have no support for multiple human languages. If you need to sup- port more than one human language for documentation purposes, mdoc is useful as it permits each language's output to reside in its own directory, and mdoc can add types/members for each separate documentation directory. * Administration. It's not unusual to have separate documentation and development teams. It's also possible that the documentation team will have minimal experience with the programming language being used. In such circumstances, inline documentation is not desirable as the documentation team could inadvertantly insert an error into the source code while updating the documentation. Alternatively, you may not want the documentation team to have access to the source code for security reasons. mdoc allows the doc- umentation to be kept completely separate and distinct from the source code used to create the assembly. Documentation can be generated using the mdoc update command: mdoc update -o docs/en ProjectName.dll Once the documentation stubs have been generated (and hopefully later filled in with actual documentation), there are three ways to view the documentation: * To generate a simple directory of HTML pages (one HTML file per type), use mdoc export-html: mdoc export-html -o /srv/www/htdocs/ProjectName docs/en * To use an ASP.NET webapp to display the sources, see: http://anonsvn.mono-project.com/source/trunk/monodoc/engine/web/. From a monodoc source checkout, you can do this: cd engine make web This will use xsp(1) to serve the ASP.NET webapp; Visit http://localhost:8080/ to view the documentation. * To use the monodoc(1) documentation browser, you must first assemble the documentation: mdoc assemble -o ProjectName docs/en The above command creates the files ProjectName.tree and ProjectName.zip. An additional ProjectName.sources file must be provided which describes where in the help system the documentation should be hooked up; it is a very simple XML file, like this: <?xml version="1.0"?> <monodoc> <source provider="ecma" basefile="ProjectName" path="various" /> </monodoc> The above configuration file describes that the documentation is in ECMA format, that the base file name is ProjectName and that it should be hooked up in the "various" part of the documentation tree. If you want to look at the various nodes defined in the docu- mentation, you can look at the monodoc.xml file which is typically installed in /usr/lib/monodoc/monodoc.xml. Once you have all of the required files (.zip, .tree and .sources) you can install them into the system with the following command: cp ProjectName.tree ProjectName.zip ProjectName.source `pkg-config monodoc --variable sourcesdir` The above will copy the files into the directory that Monodoc has registered; you might need root permissions to do this. The actual directory is returned by the pkg-config invocation. MDOC COMMANDS
mdoc assemble Compiles documentation for use within the monodoc(1) browser. See the mdoc-assemble(1) man page for details. mdoc export-html Exports documentation into a directory structure of HTML files. See the mdoc-export-html(1) man page for details. mdoc export-msxdoc Exports documentation into the single-file Microsoft XML Documentation format. See the mdoc-export-msxdoc(1) man page for details. mdoc help View internal help for a given command. mdoc help assemble is equivalent to: mdoc assemble --help Multiple sub-commands may be listed at once: mdoc help assemble export-html update validate mdoc update Updates documentation, adding and removing members based upon a reference assembly. See the mdoc-update(1) man page for details. mdoc validate Validates the documentation against the Mono documentation schema. See the mdoc-validate(1) man page for details. SEE ALSO
mdoc(5), mdoc-assemble(1), mdoc-export-html(1), mdoc-update(1), mdoc-validate(1) MAILING LISTS
Visit http://lists.ximian.com/mailman/listinfo/mono-docs-list for details. WEB SITE
Visit http://www.mono-project.com/mdoc for details mdoc(1)
All times are GMT -4. The time now is 01:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy