473,516 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create CSV/Text form XML

Hello *,

i've no expierence with XML and I hope someone can help me out with this.
Following problem:
I've an XML File and need just some parts (lines) in the result file. This
should have CSV/text style.
In this case I need only lines where dbid="feld2" or dbid="feld4".

<?xml version="1.0" encoding="UTF-8"?>
<items title="Execution">
<item>
<item_field dbid="feld1" label="Plan: Name" root="106" edit_type="list"
size="40">Hupe</item_field>
<item_field dbid="feld2" label="Plan: Date" edit_type="date"
size="10">15.02.2005</item_field>
<item_field dbid="feld3" label="Plan: Beschreibung" edit_type="memo"
size="-1">washtmlonceConnect SUT as modem to PC with Vodafone</item_field>
<item_field dbid="feld4" label="Plan: Ersteller" root="-1"
edit_type="list" size="20">Heinz</item_field>
</item>
<item>
<item_field dbid="feld1" label="Plan: Name" root="106" edit_type="list"
size="40">Honk</item_field>
<item_field dbid="feld2" label="Plan: Date" edit_type="date"
size="10">18.02.2005</item_field>
<item_field dbid="feld3" label="Plan: Beschreibung" edit_type="memo"
size="-1">washtmlonceSet up call via IrDA using AT commands with
Vodafone</item_field>
<item_field dbid="feld4" label="Plan: Ersteller" root="-1"
edit_type="list" size="20">Heino</item_field>
</item>
</items>

The result should look like this:

Plan: Date;15.02.2005;Plan: Ersteller;Heinz
Plan: Date;18.02.2005;Plan: Ersteller;Heino

I need an XLS file which does the convertion.

As converter I'm using saxon.
Thanks Stefan
Jul 20 '05 #1
3 1319
Here is the XSLT that lets you extract out the elements that you need.
You can do the formatting accordingly:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:template match="/">
<xsl:for-each select="items/item">
<xsl:for-each select="item_field[@dbid='feld2' or
@dbid='feld4']">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Jul 20 '05 #2
Hi Romin,

thanks for your answer.
This was quite close to the solution.
I changed in the following way.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:template match="/">
<xsl:for-each select="items/item">
<xsl:for-each select="item_field[@dbid='feld2' or @dbid='feld4']">
<xsl:value-of select="."/>;<xsl:text/>
</xsl:for-each>
<xsl:text>&#xa;</xsl:text>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
Could you explain the line:
<xsl:value-of select="."/>
What is this for?
Thanks Stefan

Romin wrote:
Here is the XSLT that lets you extract out the elements that you need.
You can do the formatting accordingly:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:template match="/">
<xsl:for-each select="items/item">
<xsl:for-each select="item_field[@dbid='feld2' or
@dbid='feld4']">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


Jul 20 '05 #3

Romin wrote:
Here is the XSLT that lets you extract out the elements that you need.
You can do the formatting accordingly:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:template match="/">
<xsl:for-each select="items/item">
<xsl:for-each select="item_field[@dbid='feld2' or
@dbid='feld4']">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1674
by: opt_inf_env | last post by:
Hello, Anybody know wether one can create such text-form that pointer of mouse will be automatically set in the text field of form? It means that user can type text immediately after page has been loaded, without putting pointer of mouse by hand in the text field. Thank you.
1
1881
by: kj | last post by:
Is it possible to create a form on the fly, by creating the form and its elements, and adding them to the document somehow? Thanks! kj -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded.
1
3731
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
6
2466
by: skgolden | last post by:
My husband and I own a small temporary labor company and deal with 4 major clients (A,B,C & D), each of which has about 2 dozen units in our tristate area that we deal with (ie, Company A, units a,b,c,d,e etc). We send temps possessing various skills (cashier, cook, hostess, etc) to the individual units as needed. What I'm trying to do is...
0
1055
by: Lane | last post by:
Im looking for a way to get the results from a textbox when i dynamicall create a form witha dataset Response.Write("<Form id='form1' runat='server' Method='post'>"); Response.Write("<table runat='server'>"); Response.Write("<th>Description</th><th>Size</th><th>WHSE-LOC</th><th>Stock Number</th><th>Amount</th>"); while(reader.Read()) {...
4
2736
by: Jigar Patel | last post by:
Hello, I want to create Nonrectengular form in VB.NET. Just like Windows Media Player Skins. Not Round,RoundRectengal etc.... Mean i have one Bmp and i want to create some picture portion on form. i want to remove all same color in Bmp and create just like region Form. Jigar Patel.
4
1743
by: Steven | last post by:
Hi, I have a database table field to store the form name, I want to create the particular windows form by using the value that read from that DB field. For examples, the table field has a value "ThisForm", then I want to create the form with class name "ThisForm" (Suppose I have already defined the class "ThisForm"). Can I do this by using...
3
1322
by: kpuchala | last post by:
Hello I'm beginnig to create my first application in Visual Web Debeloper 2005 Express. I need to create a web site (simple application), which will allow to list objects (records) stored in databese. This is the simple part and I managed to do this. Further I want to bind the list to a form. After klicking an object on the list, the...
2
1165
by: Mehbs | last post by:
I like to create a form and it should have multiple tab like manila foder. On first tab it should be main information regarding inventory, 2nd tab should have vendor's info, 3rd tab should have financial info, 4th tab should have history etc. I just want to know where to find that kind of form? I can put the label and text box on each tab...
8
5898
by: Paul H | last post by:
I want to base a form on a crosstab query. The query shows statistics for a user defined period. The column headings will look something like this: ClientID Month01 Month02 Month03 etc.. So if the user selects 3 months in the criteria form, there will be 3 (month) column headings, if he selects 6 months, the will be 6 headings.
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.