Sponsored Content
Top Forums Shell Programming and Scripting How to parse xml file in variable-string? Post 302658629 by OleM2k on Tuesday 19th of June 2012 03:43:46 PM
Old 06-19-2012
How to parse xml file in variable-string?

In the wake of the post: how-parse-following-xml-file
Thank you for the very useful chakrapani response 302355585-post4 !

A close question.
How to pass a file to xmllint in variable?
For example, let it be:
Code:
NEARLY_FILE='<?xml version="1.0" encoding="iso-8859-1"?><html><set label="09/07/29" value="1241.90"/></html>'

Then I want to do something like this:
Code:
echo 'cat /html' | xmllint --shell $NEARLY_FILE

and get:
Code:
<html><set label="09/07/29" value="1241.90"/></html>

Thanks in advance!
 

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

parse a string variable

Hello all, need a little help. I have an input variable such as ARGV which equals something like /use/home/name/script/test.dat I need to be able to get just the "test.dat" (i.e. the file name) at the end of the directory and the directory can be anything and any length. To put it another... (3 Replies)
Discussion started by: methos
3 Replies

3. Shell Programming and Scripting

Parse XML file

Hi, I need to parse the following XML data enclosed in <a> </a> XML tag using shell script. <X> ..... </X> <a> <b> <c>data1</c> <c>data2</c> </b> <d> <c>data3</c> </d> </a> <XX> ... </XX> (5 Replies)
Discussion started by: viki
5 Replies

4. Shell Programming and Scripting

Parse String in XML file

Hello All, I am new to this and I need to parse an XML file. Here's the XML Input File: <Report version="1.2"> <summary fatals="0" testcases="1" expected_fails="0" unexpected_passes="0" warnings="9" tests="21" errors="0" fails="1" passes="20" /> <testresult... (4 Replies)
Discussion started by: racbern
4 Replies

5. Shell Programming and Scripting

Parse a string in XML file using shell script

Hi! I'm just new here and don't know much about shell scripting. I just want to ask for help in creating a shell script that will parse a string or value of the status in the xml file. Please sample xml file below. Can you please help me create a simple script to get the value of status? Also it... (46 Replies)
Discussion started by: ayhanne
46 Replies

6. Shell Programming and Scripting

Parse String from a Variable

Hello, Is there a quick way to parse the values from a variable? The variable has the following sample input: TA= The values of the TA variable is not fixed/hardcoded Basically I need to get the IV_Test and PF_SAPP_FWK values. I created a script that first use sed to remove ,... (3 Replies)
Discussion started by: racbern
3 Replies

7. Shell Programming and Scripting

How can I parse xml file?

How can I parse file containing xml ? I am sure that its best to use perl - but my perl is not very good - can someone help? Example below contents of file containing the xml - I basically want to parse the file and have each field contained in a variable.. ie. I want to store the account... (14 Replies)
Discussion started by: frustrated1
14 Replies

8. Shell Programming and Scripting

parse xml file

Hello all, Given the following extract from a xml file with multiple <JOB> .... </JOB> entries <JOB APPLICATION="APP" APR="0" AUG="0" AUTHOR="AUT" AUTOARCH="0" CMDLINE="/tmp/test1 %%var" CONFIRM="1" CREATION_DATE="20100430" CREATION_TIME="130739" ... (2 Replies)
Discussion started by: cabrao
2 Replies

9. UNIX for Dummies Questions & Answers

Parse xml file

HI Guys, Input .XML <xn:MeContext id="L0307"> <xn:ManagedElement id="1"> <xn:VsDataContainer id="1"> <xn:attributes> <xn:vsDataType>vsDataENodeBFunction</xn:vsDataType> ... (3 Replies)
Discussion started by: pareshkp
3 Replies

10. Shell Programming and Scripting

Parse XML File.

HI Guys I have Below XML File : <xn:SubNetwork id="XYZ"> <xn:SubNetwork id="C01"> <xn:MeContext id="CO1"> <xn:ManagedElement id="1"> <un:RncFunction id="1"> <un:UtranCell id="NY431"> ... (2 Replies)
Discussion started by: pareshkp
2 Replies
xmllint(1)						      General Commands Manual							xmllint(1)

NAME
xmllint - command line XML tool SYNOPSIS
xmllint [--version | --debug | --shell | --debugent | --copy | --recover | --noent | --noout | --htmlout | --nowrap | --valid | --postvalid | --dtdvalid URL | --timing | --repeat | --insert | --compress | --sgml | --html | --push | --memory | --nowarning | --noblanks | --for- mat | --testIO | --encode encoding | --catalogs | --nocatalogs | --auto | --xinclude | --loaddtd | --dtdattr | --dropdtd] [xmlfile] INTRODUCTION
The xmllint program parses one or more XML files, specified on the command line as xmlfile. It prints various types of output, depending upon the options selected. It is useful for detecting errors both in XML code and in the XML parser itself. It is included in libxml2. OPTIONS
--version Display the version of libxml2 used. --debug Parse a file and output an annotated tree of the in-memory version of the document. --shell Run a navigating shell. --debugent Debug the entities defined in the document. --copy Test the internal copy implementation. --recover Output any parsable portions of an invalid document. --noent Substitute entity values for entity references. By default, xmllint leaves entity references in place. --noout Suppress output. By default, xmllint outputs the result tree. --htmlout Output results as an HTML file. This causes xmllint to output the necessary HTML tags surrounding the result tree output so the results can be displayed in a browser. --nowrap Do not output HTML doc wrapper. --valid Determine if the document is a valid instance of the included Document Type Definition (DTD). A DTD to be validated against also can be specified at the command line using the --dtdvalid option. By default, xmllint also checks to determine if the document is well- formed. --postvalid Validate after parsing is completed. --dtdvalid URL Use the DTD specified by URL for validation. --timing Output information about the time it takes xmllint to perform the various steps. --repeat Repeat 100 times, for timing or profiling. --insert Test for valid insertions. --compress Turn on gzip compression of output. --sgml Use the DocBook SGML parser. This allows documents written in SGML DocBook to be converted into an in-memory tree and treated as if they were written in XML. --html Use the HTML parser. --push Use the push mode of the parser. --memory Parse from memory. --nowarning Do not emit warnings from the parser and/or validator. --noblanks Drop ignorable blank spaces. --format Reformat and reindent the output. --testIO Test user input/output support. --encode encoding Output in the given encoding. --catalogs Use the catalogs from $SGML_CATALOG_FILES. Otherwise /etc/xml/catalog is used by default. --nocatalogs Do not use any catalogs. --auto Generate a small document for testing purposes. --xinclude Do XInclude processing. --loaddtd Fetch external DTD. --dtdattr Fetch external DTD and populate the tree with inherited attributes. --dropdtd Remove DTD from output. AUTHORS
John Fleck <jfleck@inkstain.net>, Ziying Sherwin <sherwin@nlm.nih.gov>, Heiko Rupp <hwr@pilhuhn.de> This is release 0.2 of the xmllint Man- ual. NOTES
Source for libxml is available in the SUNWlxmlS package. Documentation for libxml is available on-line at http://www.xmlsoft.org/ 2001 Nov 26 xmllint(1)
All times are GMT -4. The time now is 07:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy