当前位置: 动力学知识库 > 问答 > 编程问答 >

XML to HTML Conversion for complex xml

问题描述:

I am trying to convert a big xml file to html.

I have pest the part of xml file here.

in the xml file there are repetitive tags.

like header tag can be multiple time present in xml.

but inside body tag there is only one header tag.

Inside header tag there is another sub tag and I want to get all the value like Employee_B_ID, Login ID, Hire Date, Rate and display as a tabular format.

<?xml version="1.0" encoding="UTF-8"?>

<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">

------

----

-----

<body>

<image id="258">

<property name="height">0.9375in</property>

<property name="width">3.5104166666666665in</property>

<property name="source">embed</property>

<property name="imageName">logo-new - Copy.jpg</property>

</image>

<label id="245">

<property name="fontFamily">sans-serif</property>

<property name="fontSize">x-large</property>

<property name="fontWeight">bold</property>

<property name="textAlign">center</property>

<text-property name="text">Employee Information</text-property>

</label>

<table id="163">

<property name="width">100%</property>

<property name="dataSet">Data Set</property>

<property name="refTemplateParameter">NewTemplateParameterDefinition2</property>

<list-property name="paramBindings">

<structure>

<property name="paramName">b_id</property>

<simple-property-list name="expression">

<value type="javascript">params["b_id"]</value>

</simple-property-list>

</structure>

</list-property>

<list-property name="boundDataColumns">

<structure>

<property name="name">BusinessEntityID</property>

<text-property name="displayName">BusinessEntityID</text-property>

<expression name="expression" type="javascript">dataSetRow["BusinessEntityID"]</expression>

<property name="dataType">integer</property>

</structure>

<structure>

<property name="name">LoginID</property>

<text-property name="displayName">LoginID</text-property>

<expression name="expression" type="javascript">dataSetRow["LoginID"]</expression>

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">HireDate</property>

<text-property name="displayName">HireDate</text-property>

<expression name="expression" type="javascript">dataSetRow["HireDate"]</expression>

<property name="dataType">string</property>

</structure>

<structure>

<property name="name">Rate</property>

<text-property name="displayName">Rate</text-property>

<expression name="expression" type="javascript">dataSetRow["Rate"]</expression>

<property name="dataType">decimal</property>

</structure>

</list-property>

<property name="pageBreakInterval">50</property>

<column id="187"/>

<column id="188"/>

<column id="189"/>

<column id="190"/>

<header>

<row id="164">

<cell id="165">

<label id="166">

<property name="fontFamily">sans-serif</property>

<property name="fontWeight">bold</property>

<text-property name="text">Employee_B_ID</text-property>

</label>

</cell>

<cell id="167">

<label id="168">

<property name="fontFamily">sans-serif</property>

<property name="fontWeight">bold</property>

<text-property name="text">Login ID</text-property>

</label>

</cell>

<cell id="169">

<label id="170">

<property name="fontFamily">sans-serif</property>

<property name="fontWeight">bold</property>

<text-property name="text">Hire Date</text-property>

</label>

</cell>

<cell id="171">

<label id="172">

<property name="fontFamily">sans-serif</property>

<property name="fontWeight">bold</property>

<text-property name="text">Rate</text-property>

</label>

</cell>

</row>

</header>

<detail>

<row id="173">

<cell id="174">

<data id="250">

<property name="resultSetColumn">BusinessEntityID</property>

</data>

</cell>

<cell id="176">

<data id="251">

<property name="resultSetColumn">LoginID</property>

</data>

</cell>

<cell id="178">

<data id="252">

<property name="resultSetColumn">HireDate</property>

</data>

</cell>

<cell id="180">

<data id="253">

<property name="resultSetColumn">Rate</property>

</data>

</cell>

</row>

</detail>

<footer>

<row id="182">

<cell id="183"/>

<cell id="184"/>

<cell id="185"/>

<cell id="186"/>

</row>

</footer>

</table>

</body>

-------

-----

----

</report>

How to retrieve the value which is inside

 <body><header><text-property name="text">Employee_B_ID</text-property>

I need to display Employee_B_ID, Login ID, Hire Date, Rate as a tabular format.

can any one help me please.

Thanks

Ashim

网友答案:

You can use an XML parser and your favourite programming language. For different languages there are different libraries capable to parse xml for instance JAXB in java or REXML in ruby. After you parse the XML it should be relatively easy to do what you want.

分享给朋友:
您可能感兴趣的文章:
随机阅读: