Below is my xml input:
<projects>
<project>
<name >project1</name>
<language>java</language>
</project>
<project>
<name>project2</name>
<language>mainframe</language>
</project>
</projects>
I want to convert this .xml to .csv file using data-mapper, but unfortunately it doesn't work.
Can anyone send me the sample flow xml for that? It is very important for my project now.
This is a very simple requirement.
You should select your sample XML file in the input section of the datamapper and define a user defined output of type CSV. Once you create a mapping, map the fields from XML (input) to CSV (output). The code would like as below.
//MEL
//START -> DO NOT REMOVE
output.__id = str2long(input.__id);
//END -> DO NOT REMOVE
output.name = input.name;
output.language = input.language;
You can now click on Preview button and run the preview with your sample XML file. Wasn't that easy? Try this and let me if any issues.
Related
By using the query:
SELECT CAST([RESULT] as xml)
FROM [dbo].[EVENT_RESULTS]
WHERE RESULT_TYPE=21
AND ANNUALIZATION_ID = 1
I produced an xml output with of course multiple lines. Now I simply want to store this output as .xml file in the c: folder.
The output looks as follows:
enter image description here
If I klick on it, it is declared as a .xml file. But how can I store this result automatically when I run the SQL script? I don't want to do the storage "by hand", since the SQL code will be part of a BATCH Programm.
Thanks very much!
This is Working in MSSQL Server
select * from TableNamefor Xml RAW('Rec'),elements XSINIL,root('Data')
I'm new with groovy (a few weeks of experience). Currently I'm trying to process some visual studio .vcproj files using groovy: replacing some paths, that will be found by a regexp patterns. This works fine for me.
To write the changes to the file, I'm using the
XmlUtil.serialize(slurper, writer)
method, where
def writer = new FileWriter(outputFile)
and
def slurper = new XmlSlurper(keepIgnorableWhitespace:true).parse(it)
This also works fine, except one thing.
In the original vcproj file each attribute is in a separate line, like:
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\..\..\..\Test_Debug.vsprops"
CharacterSet="2"
>
but after calling the serialize() method of the XMLUtil class, the whole output is stored in one line:
<Configurations>
<Configuration Name="Debug|Win32" InheritedPropertySheets="..\..\..\..\Test_Debug.vsprops" OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="1" CharacterSet="2">
for the XMS parser this should be not a problem, but in the postprocessing some perl scripts use this vcproj file and they complain about missing CR/LF within the attribute line.
So is there any easy possibility to configure the XMLslurper or the serialize-class to keep the CR/LF in between of each attributes?
I doubt there is any easy way to format groovy's xml output to that level. Since the output is a valid XML, can't you use somekind of perl XML parser?
Other than that, you can try to match the attributes with a regex and add a line break to them. A very ugly hack:
import groovy.xml.XmlUtil
def original = '''<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\\..\\..\\..\\Test_Debug.vsprops"
CharacterSet="2"
>
</Configuration>
</Configurations>
'''
parsed = new XmlParser().parseText original
println XmlUtil.serialize(parsed).replaceAll(/[a-zA-Z]*="[^\"]*"/) {
"\n" + it
}
will print:
<?xml
version="1.0"
encoding="UTF-8"?><Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\..\..\..\Test_Debug.vsprops"
CharacterSet="2"/>
</Configurations>
Input we will get input from email,ftp etc as xml file
required output: excel file
The lovely new Mule Datamapper (mule 3.4) will process the xml to Excel, you can select and transform the required attributes.
The older approach is to process the xml and convert to csv files that can be read by most excel tools. The xml can be eaily parsed to maps and requred part output using Maps to CSV connector with the flatpack formatting file.
I have created an XML file using streamWriter.. Now, i want to remove the line breaks in my XML file.. Is there a way to accomplish this task..?
here's my sample outout
<?xml version="1.0" encoding="utf-8"?>
<!--Arbortext, Inc., 1988-2004, v.4002-->
<!DOCTYPE primary.hierarchy SYSTEM "http://phoenix.roc.westgroup.com/dtd/pax.dtd">
Output should look like this
<?xml version="1.0" encoding="utf-8"?><!--Arbortext, Inc., 1988-2004, v.4002--><!DOCTYPE primary.hierarchy SYSTEM "http://phoenix.roc.westgroup.com/dtd/pax.dtd">
Instead of using StreamWriter you can consider using XmlWriter instead. It has various settings to deal with formatting of XML output.
See XmlWriterSettings for details
BTW. I assume that have you used WriteLine with your StreamWriter approach use Write instead. That should get rid of your line breaks.
I am trying to read csv file using smooks1.4 . I want to check the field missmatch , for that in my smooks config file i am using strict="true".but it is throwing
error like this
cvc-complex-type.3.2.2: Attribute
'strict' is not allowed to appear in
element 'csv:listBinding'
this is my smooks-config.xml file
<?xml version="1.0" encoding="UTF-8"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd">
<csv:reader fields="firstName,lastName,welcome">
<csv:listBinding beanId="customerList" class="example.Customer" strict="true"/>
</csv:reader>
</smooks-resource-list>
My smooks releated Jar files are
milyn-commons-1.4.jar
milyn-smooks-core-1.4.jar
milyn-smooks-csv-1.4.jar
milyn-smooks-javabean-1.4.jar
milyn-smooks-templating-1.4.jar
Help will be appreciated.
You need to use the following URI for the csv namespace:
http://www.milyn.org/xsd/smooks/csv-1.3.xsd
Also, strict is an attribute of csv:reader, not csv:listBinding.