Create XML file dynamically from textInput fields
Hi,
I'm very new to Flex and trying to create an application that creates XML files on the users' local computer, based on a users input into textInput fields.
At the moment I'm having trouble finding how to dyamically create an external XML file at all, ideally when the user pushes a button a browseForSave dialog box will open allowing the user to select somewhere on their hard drive to create the XML file.
Can anyone give me a hint what direction I should be heading in?
Thanks
If this post answered your question or helped, please mark it as such.
You could use a SharedObject for small files, but in general Flex does not have access to the local hard drive.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="init()">
<mx:Script>
<![CDATA[
public var mySO:SharedObject;
public function init():void{
mySO = SharedObject.getLocal("mydata");
if(mySO.data.myData!=null){
var xml:XML = mySO.data.myData;
fname.text = xml.fname;
lname.text = xml.lname;
email.text = xml.email;
private function storeData():void{
var xml:XML =
<data/>;
if(fname.text != ""){
xml.appendChild(<fname>{fname.text}</fname>);
if(lname.text != ""){
xml.appendChild(<lname>{lname.text}</lname>);
if(email.text != ""){
xml.appendChild(<email>{email.text}</email>);
mySO.data.myData = xml;
mySO.flush();
private function resetData():void{
mySO.clear();
fname.text = "";
lname.text = ""
email.text = "";
]]>
</mx:Script>
<mx:Form>
<mx:FormItem label="First Name:">
<mx:TextInput id="fname"/>
</mx:FormItem>
<mx:FormItem label="Last Name:">
<mx:TextInput id="lname"/>
</mx:FormItem>
<mx:FormItem label="Email:">
<mx:TextInput id="email"/>
</mx:FormItem>
</mx:Form>
<mx:Button label="Store Data" click="storeData()"/>
<mx:Button label="Reload Stored Data" click="init()"/>
<mx:Button label="Delete Stored Data" click="resetData()"/>
</mx:Application>
Similar Messages
-
Urgent, creating xml files dynamically, request dispatcher problem
hi all,
Problem 1:
There is a problem we are facing, while request dispatching.
The files CBECBC.XML & CBECBC_Envelop.XML,
both xml files. These files are created on request from the user, dynamically, and displayed on the browser,
by including them in a jsp page.
Here we face a problem when they are to be included into the jsp page.
The error is the following :
//////// Error ////////
Could not find request dispatcher for the url CBECBC.xml
Could not find request dispatcher for the url CBECBC_Envelop.xml
The created files are stored in the "d:\pstudio35\desks\bank\BankWeb\".
We are using " <jsp:include page="...."/> " (dynamic jsp include tag), to include the xml files.
Problem 2:
And could you just let me know how to include a xml file in a jsp file,
so that the xml file is displayed in the exact format of xml(with the tags).
I am using Pramati Studio 3.5
Its urgent!!!
Regards,
Deepa Datarproblem 2:
either translate all < en > into < and > or display the XML in a textarea -
How to creat XML file dynamically
i want to create a XML file where tags will be dynamically created based on the backend table feild name.After creating this table i want to insert this XML file into a table as a feild.
Here is some pseudo to output a database contents to file.
Writer.write("<Root>")
//for each database d
Writer.write("<" + d.getName() + ">")
// for each table t in d
Writer.write("<" + t.getName() + ">")
//for each row r in t
Writer.write("<Row>")
//for each column c in r
Writer.write("<" + c.getName() + " >" + c.getValue() + "</" + c.getName() + ">");
//end for
Writer.write("</Row>")
//end for
Writer.write("</" + t.getName() + ">")
//end for
Writer.write("</" + d.getName() + ">")
Writer.write("</Root>") -
How can I create xml file automatically from database
Hi,
Can I create a site map drom database.There is table for storing menu details.Is it possible to create an xml file corresponding to a query.
How can i configure root menu.xml to incllude this xml file.Please help me..
ThanksIs your question pertaining to an answer regarding JDeveloper, or you just want an XML file? If XML, have you considered looking at the Oracle db XML DB feature set?
CM. -
Generate XML file dynamically using java
Hi,
I searched on this topic on the net and also in this forum but everything leads to parsing an existing file using JAXP technology. But i need to create an xml file dynamically from the data coming from a different source. I can do it manually by writting the content to a file. But i am sure there is a better way for it. I would be obliged if some one could give me and example java class which produces a simple xml file or direct me to any resource online.
Thank you in advance.Yes you can create the xml file dynamically. Like this,
BufferedWriter bw = new BufferedWriter(new FileWriter("xyz.xml"));
bw.write(buffer.toString()); //where buffer is StringBuffer whcih contains the your xml data
bw.close();
Remember to close the BufferedWriter, otherwise it will create the file but don't write anything.
Hope this will help u.
....yogesh -
Creating xml file from fields of a fmb
Hi,
What i want to do is to create a "generic" button (which can work for all forms of my application) which ables the application to create a xml file completed with all fields on my form. The matter is that i can't know by advance all fields of my 1100 forms!
Is there a solution?
Kind regards
PS: i have forms6 but soon forms10
PS2: sorry for my poor englishHello,
It is easy to loop through all items of a form.
Have a look at the Dynamic Color Customization white paper on OTN. get the sources code and study the COLOR.PLL functions.
http://www.oracle.com/technology/products/forms/pdf/10g/community_colors.zip
Francois -
Create XML file on application server (unix directory) from internal table
Hallo everybody,
I have got the following problem:
I am working with <u><b>release 4.6C</b></u> and have got to create XML files from HR master data and organizational data respectively.
This takes place in 3 steps:
1. Collect the data in an internal table
2. Convert the data to XML format using the function module 'SAP_CONVERT_TO_XML_FORMAT'
3. Download the data
If I download the converted data, which are in an internal table, to the presentation server via the function module WS_DOWNLOAD and open it with the Internet Explorer, everything is ok.
If I download the converted data to the application server, i.e. into a unix directory via
open dataset, loop at internal table, transfer working area to file, close dataset
and then try to open it, this is not possible, because after the last tag some unreadable characters, e.g. a square, appear that arent supposed to be there. Thats what my colleagues told me, for I havent got access to the server.
I have no idea where these characters come from and how I can get rid of them. I guess that either I have to modify (how?) the table with the converted data before the download or I have to use another way to convert the data. For the second way I would probably have to work with an XML class or an XML interface. Unfortunately II am not an expert in working with classes so sample coding would have to be rather detailed.
Heres some more information about how I work with the conversion function module:
call function 'SAP_CONVERT_TO_XML_FORMAT'
exporting
i_field_seperator = lv_field_seperator
i_line_header = lv_line_header
i_filename = lv_xml_file
i_appl_keep = ' '
i_xml_doc_name = lv_xml_doc_name
importing
pe_bin_filesize = lv_result
tables
i_tab_sap_data = gt_data
changing
i_tab_converted_data = lt_tab_converted_data
exceptions
conversion_failed = 1
others = 2.
lv_field_seperator = X.
lv_xml_doc_name = Personalstammdaten Publikation
lv_result: type i
gt_data: fields: PERNR, PERSG, PERSK etc.
types:
begin of truxs_xml_line,
data(256) type x,
end of truxs_xml_line.
types:
truxs_xml_table type table of truxs_xml_line.
data:
lv_tab_converted_data type truxs_xml_line,
lt_tab_converted_data type truxs_xml_table
open dataset lv_xml_file for output in binary mode.
loop at lt_tab_converted_data into lv_tab_converted_data.
transfer lv_tab_converted_data to lv_xml_file.
endloop.
close dataset lv_xml_file
lv_xml_file: /usr/users/.../.../Personendaten_2004-11-02.xml
Hope the information is detailed enough! Otherwise let me know. Thank you in advance.
Message was edited by: Johannes SchwehmHi Raja,
tried the "TEXT" mode, but that didn't help.
There are still characters after the last tag, that are not supposed to be there including a date that is not
the creation date of the file.
Thank you for your help.
Regards
Johannes -
Create xml file with values from context
Hi experts!
I am trying to implement a WD application that will have some input fields, the value of those input fields will be used to create an xml file with a certain format and then sent to a certain application.
Apart from this i want to read an xml file back from the application and then fill some other context nodes with values from the xml file.
Is there any standard used code to do this??
If not how can i do this???
Thanx in advance!!!
P.S. Points will be rewarded to all usefull answers.
Edited by: Armin Reichert on Jun 30, 2008 6:12 PM
Please stop this P.S. nonsense!Hi,
you need to create three util class for that:-
XMLHandler
XMLParser
XMLBuilder
for example in my XML two tag item will be there e.g. Title and Organizer,and from ur WebDynpro view you need to pass value for the XML tag.
And u need to call buildXML()function of builder class to generate XML, in that i have passed bean object to get the values of tags. you need to set the value in bean from the view ui context.
Code for XMLBuilder:-
Created on Apr 4, 2006
Author-Anish
This class is to created for having function for to build XML
and to get EncodedXML
and to get formated date
package com.idb.events.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.idb.events.Event;
public class XMLBuilder {
This attribute represents the XML version
private static final double VERSION_NUMBER = 1.0;
This attribute represents the encoding
private static final String ENCODING_TYPE = "UTF-16";
/*Begin of Function to buildXML
return: String
input: Event
public String buildXML(Event event) {
StringBuffer xmlBuilder = new StringBuffer("<?xml version=\"");
xmlBuilder.append(VERSION_NUMBER);
xmlBuilder.append("\" encoding=\"");
xmlBuilder.append(ENCODING_TYPE);
xmlBuilder.append("\" ?>");
xmlBuilder.append("<event>");
xmlBuilder.append(getEncodedXML(event.getTitle(), "title"));
xmlBuilder.append(getEncodedXML(event.getOrganizer(), "organizer"));
xmlBuilder.append("</event>");
return xmlBuilder.toString();
/End of Function to buildXML/
/*Begin of Function to get EncodedXML
return: String
input: String,String
public String getEncodedXML(String xmlString, String tag) {
StringBuffer begin = new StringBuffer("");
if ((tag != null) || (!tag.equalsIgnoreCase("null"))) {
begin.append("<").append(tag).append(">");
begin.append("<![CDATA[");
begin.append(xmlString).append("]]>").append("</").append(
tag).append(
">");
return begin.toString();
/End of Function to get EncodedXML/
/*Begin of Function to get formated date
return: String
input: Date
private final String formatDate(Date inputDateStr) {
String date;
try {
SimpleDateFormat simpleDateFormat =
new SimpleDateFormat("yyyy-MM-dd");
date = simpleDateFormat.format(inputDateStr);
} catch (Exception e) {
return "";
return date;
/End of Function to get formated date/
Code for XMLParser:-
Created on Apr 12, 2006
Author-Anish
This is a parser class
package com.idb.events.util;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import com.idb.events.Event;
import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
public class XMLParser {
Enables namespace functionality in parser
private final boolean isNameSpaceAware = true;
Enables validation in parser
private final boolean isValidating = true;
The SAX parser used to parse the xml
private SAXParser parser;
The XML reader used by the SAX parser
private XMLReader reader;
This method creates the parser to parse the user details xml.
private void createParser()
throws SAXException, ParserConfigurationException {
// Create a JAXP SAXParserFactory and configure it
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
saxFactory.setNamespaceAware(isNameSpaceAware);
saxFactory.setValidating(isValidating);
// Create a JAXP SAXParser
parser = saxFactory.newSAXParser();
// Get the encapsulated SAX XMLReader
reader = parser.getXMLReader();
// Set the ErrorHandler
This method is used to collect the user details.
public Event getEvent(
String newsXML,
XMLHandler xmlHandler,
IWDMessageManager mgr)
throws SAXException, ParserConfigurationException, IOException {
//create the parser, if not already done
if (parser == null) {
this.createParser();
//set the parser handler to extract the
reader.setErrorHandler(xmlHandler);
reader.setContentHandler(xmlHandler);
InputSource source =
new InputSource(new ByteArrayInputStream(newsXML.getBytes()));
reader.parse(source);
//return the results of the parse
return xmlHandler.getEvent(mgr);
Code for XMLHandler:-
Created on Apr 12, 2006
Author-Anish
This is a parser class
package com.idb.events.util;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import com.idb.events.Event;
Created on Apr 12, 2006
Author-Anish
*This handler class is created to have constant value for variables and function for get events,
character values for bean variable,
parsing thr date ......etc
package com.idb.events.util;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
import java.util.*;
import com.idb.events.Event;
import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
public class XMLHandler extends DefaultHandler {
private static final String TITLE = "title";
private static final String ORGANIZER = "organizer";
IWDMessageManager manager;
private Event events;
private String tagName;
public void setManager(IWDMessageManager mgr) {
manager = mgr;
This function is created to get events
public Event getEvent(IWDMessageManager mgr) {
manager = mgr;
return this.events;
This function is created to get character for setting values through event's bean setter method
public void characters(char[] charArray, int startVal, int length)
throws SAXException {
String tagValue = new String(charArray, startVal, length);
if (TITLE.equals(this.tagName)) {
this.events.setTitle(tagValue);
if (ORGANIZER.equals(this.tagName)) {
String orgName = tagValue;
try {
orgName = getOrgName(orgName);
} catch (Exception ex) {
this.events.setOrganizer(orgName);
This function is created to parse boolean.
private final boolean parseBoolean(String inputBooleanStr) {
boolean b;
if (inputBooleanStr.equals("true")) {
b = true;
} else {
b = false;
return b;
This function is used to call the super constructor.
public void endElement(String uri, String localName, String qName)
throws SAXException {
super.endElement(uri, localName, qName);
/* (non-Javadoc)
@see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
This function is used to call the super constructor.
public void fatalError(SAXParseException e) throws SAXException {
super.fatalError(e);
This function is created to set the elements base on the tag name.
public void startElement(
String uri,
String localName,
String qName,
Attributes attributes)
throws SAXException {
this.tagName = localName;
if (ROOT.equals(tagName)) {
this.events = new Event();
public static void main(String a[]) {
String cntry = "Nigeria";
XMLHandler xml = new XMLHandler();
ArrayList engList = new ArrayList();
engList = xml.getCountries();
ArrayList arList = xml.getArabicCountries();
int engIndex = engList.indexOf(cntry);
System.out.println("engIndex :: " + engIndex);
String arCntryName = (String) arList.get(engIndex);
System.out.println(
">>>>>>>>>>>>>>>>>>>>" + xml.getArabicCountryName(cntry));
Hope that may help you.
If need any help , you are most welcome.
Regards,
Deepak -
Xml publisher enterprise!!! create rtf file dynamically with load xml data
i am new to xml publisher enterprise , i want a solution for this question ...
i want create rtf file dynamically with loading xml data....means i wrote a program in jsp where the the output in xml file simultaneously create rtf file..but i enable load the xml data in rtf file but when i goto rtf file from where data in that load xml then it genrate the columns..but i want in dynamiclly to load the data will you please guide me ......Hi Atiq
Im not quite clear on the requirement here:
1. Do you just want to be able to extract the data and apply a template to the XML data from your jdp and render output?
If so then you can use the XMLP APIs ... the are in the user guide. Particularly:
RTFProcessor - converts RTF template to XSLFO stylesheet
FOProcessor - takes, XML data, XSLFO stylesheet and output format and generates the required output.
2. Do you want a template that will accept any data and just format it into rows and columns ? This can be written but your XML structure is going to have to be static, the data of course can be dynamic.
Regards, Tim -
Creating XML file from Java Bean
Hi
Are there any standard methods in Java 1.5 to create XML file from java bean,
i can use JAXB or castor to do so,
But i would like to know if there is any thing in java core classes,
I have seen XMLEncoder, but this is not what i want.
Any ideas
AshishMarshall JavaBean to an XML document with JAXB or XMLBeans.
-
How to create xml file from Oracle and sending the same xml file to an url
How to create xml file from Oracle and sending the same xml file to an url
SQL/XML (XMLElement, XMLForest, XMLAgg, etc) and UTL_HTTP.
Whether that works for you with the version of Oracle you have, your requirements, and needs is another story. A little detail goes a long way. -
Create XML File from a specified XSD file
Hi,
I'd like to create an XML document with java. BUT How can we "bind" this creation with a XSD file. Hence, the creation may fail if the XSD binded file is not respected.
So I know how to create XML file but not bind to this creation my proper XSD file (XML schema). With which tool can I do this ?
Thanks.Hi,
I'd like to create an XML document with java. BUT How can we "bind" this creation with a XSD file. Hence, the creation may fail if the XSD binded file is not respected.
So I know how to create XML file but not bind to this creation my proper XSD file (XML schema). With which tool can I do this ?
Thanks. -
Can not create XML file from MS Access 2003
Hi,
I am getting error as "Error loading in DLL" when I use msaccess_exporter to create XML file for migrations usind Access 2003 DB. Does anyone know about this? If yes, could you please let me know how to resolve it?
Thanks,
KartikHi Daniel,
I believe you are seeing the message "Table'_OracletblDatabase' already exists" because you are attempting to export an MDB file that you previously attempted to export, but that initial export process may not have run to completion. I recommend opening your .MDB file, and delete any "_Oracletbl..." table objects that exist under the list of Table objects. Close the MDB file and carry out the export process again. You should now be able to use the 2000 mde file.
I hope this helps.
Regards,
Hilary -
How I can differentiate xml files coming from XI?
Hi all,
I have a dilemma!!! Im using NW Portal to publish logs from R/3; this is made with file adapter. At the moment, this file adapter only uses one shared folder as a repository in Portal and it works well.
But, in future I will have a lot of different messages to process, or either, one message per organism. Because a variety of organism will use the same interface to send files to R/3, I need to differentiate all these organisms.
So, when organism A sends the files to R/3 and it goes to Portal to see the log of these transactions, it can only see the log of your messages. So I think in one repository folder per organism and with this we can guarantee that only the organism sees your respective logs. (In xml message I have a field code for which organism).
My question is: There is a way, in runtime, to check the content of xml file and read this field code to verify what organism is and put the file in respective folder?
Anybody have an idea how I do something like that?
Thanks in advance,
Ricardo.Hi again Michal,
Im trying this:
Using ABAP Proxy to connect R3 -> XI and a simple receiver file adapter to place the log files in a new temporary content folder. In same business system I created two more file adapters, a sender with "Adapter Specific Message Properties", which tell the adapter to include those properties inside the SOAP message and with delete processing mode to maintaining clear the temporary content folder. And a receiver file adapter with those properties checked too, through program mapping with the user defined function to get the target directory.
But I continues without a DynamicConfiguration section in my SOAP header of Inbound message (CENTRAL).
And when I open the message the tag wit the directory path have the null code.
<DIR_PATH>null</DIR_PATH>
It means that something in user-defined function are wrong! Should I put something in field imports of User-defined function that I have created?
Java code:
imports (blank)
public String getTargetDirectory(String a,Container container){
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
String ourSourceDirectory = conf.get(key);
return ourSourceDirectory;
Like I said my knowledge about java is very poor, do you see any error in this java code?
Thanks again for your great help.
Ricardo. -
Can I bind a xml file dynamically to a form? say, bind to a different xml file after user select a value from a drop down list in the form?how to do it? Thanks.
I think it's best to create different XPD files for each language and add an XML tag <language>countryCode</language> to your XML dataset and XSD file. this way you could tell the workbench to use a different xpd file for generating the PDF file.
Anyway if you want to load an XML file from your local filesystem you should check out this URL: http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm it shows you how to read & write files using javascript.
The problem you'll be facing is editing the binding and reading + validating the given XML file. Especially validating the XML vs the XSD file used in the designer will probably cause a few errors, yet this is highly recommended in order to make sure you're not modifying your PDF with the wrong (or even malicious) data.
Security-wise i would not implement it your way but make a different XPD file for each language. In the LiveCycle Workbench you can select the correct XPD file based on the data you provide. Then it's just the user who needs to specify his/her language and your pdf is always build correctly. Yet I do not know if this is applicable to your situation and/or needs.
Maybe you are looking for
-
ABS WINE issue, or simply looking for 20041019 package
Hello folks. I am having a slight problem with WINE. I am in need of wine 20041019 package. I used to be able to run foobar2000 on WINE 20041019 flawlessly, with no redraw problem or anything and it was simply working like native. However, at one poi
-
Oracle Sqldeveloper and *.xsd Files
Hi, I've been playing with writing some simple sqldeveloper xml extensions. I ran across this link: http://wiki.oracle.com/page/SQL+Dev+SDK+How+To+create+an+XML+User+Defined+Extension Extension Framework SQL Developer database navigator, database obj
-
Hello, I have a requirement, wherin there are 10 tables for which the data changed/inserted/deleted for any field needs to be transferred to third party. I have gone through the change pointer concept and found that SAP does not recommend this as thi
-
How to resolve that problem?
After removal of my last posting I try a censored version of my problem: I had an important job two days ago. When I imported the pictures to my old (upgraded from v2) lib the pictures that I exported as JPG were scrambled in blocks. I tried to repai
-
Why won't Firefox 7 stay on a website?
When I go to a website, the page loads normally and seems to work for about 3-5 seconds. Then Firefox goes into connection mode--I don't know what it is trying to connect to. It can't find the page its looking for and I get redirected to a 404 error