Sponsored Content
Full Discussion: Parsing XML file
Top Forums UNIX for Dummies Questions & Answers Parsing XML file Post 302904049 by Akshay Hegde on Sunday 1st of June 2014 01:59:17 PM
Old 06-01-2014
@ms2001 : if you just post sample data , what we have to think ? don't think that others will guess and answer you., from your last 2 sample it looks like you did not read Don Cragun's answer., without clear description we can't help.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Parsing xml file using Sed

Hi All, I have this(.xml) file as: <!-- define your instance here --> <instance name='ins_C2Londondev' user='' group='' fullname='B2%20-%20London%20(dev)' > <property> </property> </instance> I want output as: <!-- define your instance here --> <instance... (3 Replies)
Discussion started by: kapilkinha
3 Replies

2. Shell Programming and Scripting

XML file parsing using script

Hi I need some help with XML file parsing. I have an XML file with the below tag, I need a script to identify the value of srvcName which is this case is "AAA srvc name". I need to put contents of this value which is AAA srvc and name into different variables using an array and then reformat it... (6 Replies)
Discussion started by: zmfcat1
6 Replies

3. UNIX for Dummies Questions & Answers

Help parsing a XML file ....

Well I have read several threads on the subject ... but being a newbie like me makes it hard to understand ... What I need is the following: Input data: ------- snip --------- <FavouriteLocations> <FavouriteLocations class="FavouriteList"><Item... (6 Replies)
Discussion started by: misak
6 Replies

4. Shell Programming and Scripting

Parsing xml file

hi guys, great help to the original question, can i expand please? i have large files filled with blocks like this <Placemark> network type: hot line1 line2 line3 <styleUrl>red.png</styleUrl> </Placemark> <Placemark> network type: cold line1 line2 line3... (3 Replies)
Discussion started by: garvald
3 Replies

5. Shell Programming and Scripting

Help in parsing xml file (sed/nawk)

I have a large xml file as shown below: <input> <blah> <blah> <atr="blah blah value = ""> <blah> <blah> </input> ..2nd chunk... ..3rd chunk... ...4th chunk... All lines between <input> and </input> is one 'order' and this 'order' is repeated... (14 Replies)
Discussion started by: shekhar2010us
14 Replies

6. Shell Programming and Scripting

parsing xml file

Hello! We need to parse weblogic config.xml file and display rows in format: machine:listen-port:name:application_name In our enviroment the output should be (one line for every instance): Crm-Test-Web:8001:PIA:peoplesoft Crm-Test-Web:8011:PIA:peoplesoft... (9 Replies)
Discussion started by: annar
9 Replies

7. Shell Programming and Scripting

Parsing an XML file

Hello, I have the following xml file as an input. <?xml version="1.0" encoding="UTF-8"?> <RECORDS PS3_VERSION="1104_01"><RECORD> <POI_ID>931</POI_ID> <SUPPLIER_ID>2</SUPPLIER_ID> <POI_PVID>997920846</POI_PVID> <DB_ID>1366650925</DB_ID> <REGION>H1</REGION> <POI_NAME NAME_TYPE="Official"... (4 Replies)
Discussion started by: ramky79
4 Replies

8. Shell Programming and Scripting

Help in parsing XML output file in perl.

Hi I have an XML output like : <?xml version="1.0" encoding="ISO-8859-1" ?> - <envelope> - <body> - <outputGetUsageSummary> - <usgSumm rerateDone="5"> - <usageAccum accumId="269" accumCaptn="VD_DP_AR" inclUnits="9999999.00" inclUnitsUsed="0.00" shared="false" pooled="false"... (7 Replies)
Discussion started by: rkrish
7 Replies

9. Shell Programming and Scripting

XML: parsing of the Google contacts XML file

I am trying to parse the XML Google contact file using tools like xmllint and I even dived into the XSL Style Sheets using xsltproc but I get nowhere. I can not supply any sample file as it contains private data but you can download your own contacts using this script: #!/bin/sh # imports... (9 Replies)
Discussion started by: ripat
9 Replies

10. Shell Programming and Scripting

Help with parsing xml file

Hi, Need help with parsing xml data in unix and place it in a csv file. My xml file looks like this: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <iwgroups> <nextid value="128"> </nextid> <iwgroup name="RXapproval" id="124" display-name="RXapproval"... (11 Replies)
Discussion started by: ajayakunuri
11 Replies
XSLT_PROCESS(3) 							 1							   XSLT_PROCESS(3)

xslt_process - Perform anXSLTtransformation

SYNOPSIS
mixed xslt_process (resource $xh, string $xmlcontainer, string $xslcontainer, [string $resultcontainer], [array $arguments], [array $parameters]) DESCRIPTION
The xslt_process(3) function is the crux of the XSLT extension. It allows you to perform an XSLT transformation using almost any type of input source - the containers. This is accomplished through the use of argument buffers -- a concept taken from the SablotronXSLT processor (currently the only XSLT processor this extension supports). The input containers default to a filename 'containing' the document to be processed. PARAMETERS
o $ xh -The XSLT processor link identifier, created with xslt_create(3). o $xmlcontainer - Path to XML file or placeholder for the XML argument. o $xslcontainer - Path to XSL file or placeholder for the XML argument. o $resultcontainer - The result container defaults to a filename for the transformed document. If the result container is not specified - i.e. NULL - than the result is returned. o $arguments - Instead of files as the XML and XSLT arguments to the xslt_process(3) function, you can specify "argument place holders" which are then substituted by values given in the $arguments array. o $parameters - An array for any top-level parameters that will be passed to the XSLT document. These parameters can then be accessed within your XSL files using the <xsl:param name="parameter_name"> instruction. The parameters must be UTF-8 encoded and their values will be interpreted as strings by the Sablotron processor. In other words - you cannot pass node-sets as parameters to the XSLT docu- ment. Containers can also be set via the $arguments array (see below). RETURN VALUES
Returns TRUE on success or FALSE on failure. If the result container is not specified - i.e. NULL - than the result is returned. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 4.0.6 | | | | | | | This function no longer takes XML strings in | | | $xmlcontainer or $xslcontainer. Passing a string | | | containing XML to either of these parameters will | | | result in a segmentation fault in Sablotron ver- | | | sions up to and including version 0.95. | | | | +--------+---------------------------------------------------+ EXAMPLES
The simplest type of transformation with the xslt_process(3) function is the transformation of an XML file with an XSLT file, placing the result in a third file containing the new XML (or HTML) document. Doing this with Sablotron is really quite easy... Example #1 Using the xslt_process(3) to transform an XML file and a XSL file to a new XML file <?php // Allocate a new XSLT processor $xh = xslt_create(); // Process the document if (xslt_process($xh, 'sample.xml', 'sample.xsl', 'result.xml')) { echo "SUCCESS, sample.xml was transformed by sample.xsl into result.xml"; echo ", result.xml has the following contents <br /> "; echo "<pre> "; readfile('result.xml'); echo "</pre> "; } else { echo "Sorry, sample.xml could not be transformed by sample.xsl into"; echo " result.xml the reason is that " . xslt_error($xh) . " and the "; echo "error code is " . xslt_errno($xh); } xslt_free($xh); ?> While this functionality is great, many times, especially in a web environment, you want to be able to print out your results directly. Therefore, if you omit the third argument to the xslt_process(3) function (or provide a NULL value for the argument), it will automatically return the value of the XSLT transformation, instead of writing it to a file... Example #2 Using the xslt_process(3) to transform an XML file and a XSL file to a variable containing the resulting XML data <?php // Allocate a new XSLT processor $xh = xslt_create(); // Process the document, returning the result into the $result variable $result = xslt_process($xh, 'sample.xml', 'sample.xsl'); if ($result) { echo "SUCCESS, sample.xml was transformed by sample.xsl into the $result"; echo " variable, the $result variable has the following contents <br /> "; echo "<pre> "; echo $result; echo "</pre> "; } else { echo "Sorry, sample.xml could not be transformed by sample.xsl into"; echo " the $result variable the reason is that " . xslt_error($xh); echo " and the error code is " . xslt_errno($xh); } xslt_free($xh); ?> The above two cases are the two simplest cases there are when it comes to XSLT transformation and I'd dare say that they are the most com- mon cases, however, sometimes you get your XML and XSLT code from external sources, such as a database or a socket. In these cases you'll have the XML and/or XSLT data in a variable -- and in production applications the overhead of dumping these to file may be too much. This is where XSLT's "argument" syntax, comes to the rescue. Instead of files as the XML and XSLT arguments to the xslt_process(3) function, you can specify "argument place holders" which are then substituted by values given in the arguments array (5th parameter to the xslt_process(3) function). The following is an example of processing XML and XSLT into a result variable without the use of files at all. Example #3 Using the xslt_process(3) to transform a variable containing XML data and a variable containing XSL data into a variable containing the resulting XML data <?php // $xml and $xsl contain the XML and XSL data $arguments = array( '/_xml' => $xml, '/_xsl' => $xsl ); // Allocate a new XSLT processor $xh = xslt_create(); // Process the document $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); if ($result) { echo "SUCCESS, sample.xml was transformed by sample.xsl into the $result"; echo " variable, the $result variable has the following contents <br /> "; echo "<pre> "; echo $result; echo "</pre> "; } else { echo "Sorry, sample.xml could not be transformed by sample.xsl into"; echo " the $result variable the reason is that " . xslt_error($xh); echo " and the error code is " . xslt_errno($xh); } xslt_free($xh); ?> Example #4 Passing PHP variables to XSL files <?php // XML string $xml = '<?xml version="1.0"?> <para> change me </para>'; // XSL string $xsl = ' <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="ISO-8859-1" indent="no" omit-xml-declaration="yes" media-type="text/html"/> <xsl:param name="myvar"/> <xsl:param name="mynode"/> <xsl:template match="/"> My PHP variable : <xsl:value-of select="$myvar"/><br /> My node set : <xsl:value-of select="$mynode"/> </xsl:template> </xsl:stylesheet>'; $xh = xslt_create(); // the second parameter will be interpreted as a string $parameters = array ( 'myvar' => 'test', 'mynode' => '<foo>bar</foo>' ); $arguments = array ( '/_xml' => $xml, '/_xsl' => $xsl ); echo xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments, $parameters); ?> The above example will output: My PHP variable : test<br> My node set : &lt;foo&gt;bar&lt;/foo&gt; NOTES
Note Please note that file:// is needed in front of the path when using Windows. PHP Documentation Group XSLT_PROCESS(3)
All times are GMT -4. The time now is 03:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy