How to bind to local xml file?
I have a local XML file referenced in my Declarations tag:
<fx:Declarations>
<fx:XML id="myXMLdata" source="assets/names.xml" />
</fx:Declarations>
I previously had a proof of concept version working with the XML defined in my MXML with a bindable tag:
[Bindable]
public var names : XML= <root>
etc., etc.
I need to place the xml in a separate local file so that changes to the file will persist.
How do I do this and bind to it?
thanks
MCE
http://www.adobe.com/devnet/air/flex/quickstart/xml_prefs.html - This should help you, i guess.
In short,
private function saveXML():void
personXML.firstName = fName_txti.text;
personXML.lastName = lName_txti.text;
var newXMLStr:String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + personXML.toXMLString();
var fs:FileStream = new FileStream();
fs.open(file, FileMode.WRITE);
fs.writeUTFBytes(newXMLStr);
fs.close();
This function can be the eventHandler function for, say an XML change event etc.
Hope this helps,
Balakrishnan V
Similar Messages
-
How I can create a XML file from java Aplication
How I can create a XML file from java Aplication
whith have a the following structure
<users>
<user>
<login>anyName</login>
<password>xxxx</password>
</user>
</users>
the password label must be encripted
accept any suggestionLet us assume you have all the data from the jsp form in an java bean object..
Now you want a xml file. This can be acheived in 2 ways
1. Write it into a file using java.io classes. Say you have a class with name
write("<name>"+obj.getName+</name>);
bingo you have a flat file with the xml
2. Use data binding to do the trick
will recommend JiBx and Castor for the 2nd option
Regards,
Rajagopal -
Hi, I would like to work with a local xml file, but I don't want to point to a strict location as I would like my application to run on a few different machines.
Is there a special place within Netbeans project structure that I can place such files?
Say if I try and load a file "somefile.xml" - where is it going to look first?
I have a <default package> with my settings.xml in there. How can I reference this within my app?
Edited by: 993541 on Mar 16, 2013 9:25 AM993541 wrote:
Is there a special place within Netbeans project structure that I can place such files?dunno Netbeans project structure at all but I'd sugest maven project structure wich is widely used: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
There you would place such a file in the <tt>main/resources</tt> folder
Say if I try and load a file "somefile.xml" - where is it going to look first?I'ts going to look for it where you tell your program to.
When created as <tt>new File("somefile.xml")</tt> it will bee searched in the <i>currend working directory</i>. The problem with that is that it is unreliable what this will be at runtime (once your Program left your IDE...).
You should better get it via <tt>getClass().getResource("somefile.xml")</tt> But in this case the file must be present in the classpath in the same package as the Class aquireing it. Adding a <tt>'/'</tt> in front of the file name expects it in the root directory of a classpath entry.
I have a <default package> with my settings.xml in there. How can I reference this within my app?<tt>getClass().getResource("/settings.xml")</tt>
But in case you include it into the delivery jar file it will not be writable. Also you cannot expect the installation folder of your App to be writable. On startup of your program you should copy your (default) settings to a writable place like <tt>new File(System.getProperty("user.home2),".myApp/settings.xml");</tt> and modify it there.
bye
TPD -
How can i transfer the xml files between different systems?
hello
the appearance of xml enable the inter-communication between differences systems.but
i don't know how,such as following scinario:
in the client side,we use the console that is written by using c#,if i finish
filling the text boxes that are within the console,click the submit button,the
console will generate a xml format document.i want the other application that
is written by using jsp and servlet and deployed in weblogic server to receive
the xml document,then process the document.
but i don't know how i can transfer the xml files between the two applications
that is written in different languages? can i use http protocol?
thanks for any helps!Yes, you can use the HTTP protocol as a transport for the XML message, this
is basically what the HTTP binding for SOAP does. The key is using a
packaging mechanism that different applications will understand, otherwise
only your own applications will know how to extract and process the XML
messages you send between them.
"zbcong" <[email protected]> wrote in message
news:3e68318e$[email protected]..
>
hello
the appearance of xml enable the inter-communication between differencessystems.but
i don't know how,such as following scinario:
in the client side,we use the console that is written by using c#,if ifinish
filling the text boxes that are within the console,click the submitbutton,the
console will generate a xml format document.i want the other applicationthat
is written by using jsp and servlet and deployed in weblogic server toreceive
the xml document,then process the document.
but i don't know how i can transfer the xml files between the twoapplications
that is written in different languages? can i use http protocol?
thanks for any helps! -
How to retrieve value from xml file
hi all,
can somebody pls tell me how to retrieve value from xml file using SAXParser.
I want to retrieve value of only one tag and have to perform some validation with that value.
it's urgent .
pls help me out
thnx in adv.
rituhi shanu,
the pbm is solved, now i m able to access XXX no. in action class & i m able to validate it. The only thing which i want to know is it ok to declare static ArrayList as i have done in this code. i mean will it affect the performance or functionality of the system.
pls have a look at the following code snippet.
public class XMLValidator {
static ArrayList strXXX = new ArrayList();
public void validate(){
factory.setValidating(true);
parser = factory.newSAXParser();
//all factory code is here only
parser.parse(xmlURI, new XMLErrorHandler());
public void setXXX(String pstrXXX){
strUpn.add(pstrXXX);
public ArrayList getXXX(){
return strXXX;
class XMLErrorHandler extends DefaultHandler {
String tagName = "";
String tagValue = "";
String applicationRefNo = "";
String XXXValue ="";
String XXXNo = "";
XMLValidator objXmlValidator = new XMLValidator();
public void startElement(String uri, String name, String qName, Attributes atts) {
tagName = qName;
public void characters(char ch[], int start, int length) {
if ("Reference".equals(tagName)) {
tagValue = new String(ch, start, length).trim();
if (tagValue.length() > 0) {
RefNo = new String(ch, start, length);
if ("XXX".equals(tagName)) {
XXXValue = new String(ch, start, length).trim();
if (XXXValue.length() > 0) {
XXXNo = new String(ch, start, length);
public void endElement(String uri, String localName, String qName) throws SAXException {
if(qName.equalsIgnoreCase("XXX")) {
objXmlValidator.setXXX(XXXNo);
thnx & Regards,
ritu -
How to Read and Generate XML file from java code.
hi guys,
how to read the xml file (Condition :we know only DTD or Shema only).
How to Generate the new xml file ?(using Shema )
And one more how directly Generate the xml from DB?
Pleas with code or any URLUsing XMLbeans you can generate Java objects from an XSD schema (perhaps DTDs aswell)
Then you can create an instance of the Document object and ask it to write itself.
This will create an XML document complient to the schema.
XMLBeans generates a "type" safe DOM where you can only ever have a structure compilent to you schema.
matfud -
How I could generate an XML file from a report in version 4.0B
Good morning,
How could I generate an XML file from a report? Please note that I am using version 4.0B
I don't have access to
Billy VitalHi,
In the Class CL_XML_DOCUMENT,
we have a method EXPORT_TO_FILE to download an XML file. -
How To check validity of XML File
can any one tell me how to find whether an XML file is valid or not before beginning to parse the XML file
Thanks in advanceXerces will do that for qou, if you activate validation (and, of course, a DTD is specified in the file). Read the documentation of Xerces at xml.apache.org
-
How to remove Unicode from XML file
I get following error when unmarshal xml:
[java] org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x15) was found in the element content of the document.
Anyone know how to remove Unicode from xml file? Can I remove the unicode by rebuild the file?
ThanksThese sort of error usually occur when you're using a different character encoding to read the file than the one you wrote it with. Perhaps if you were to post the problem section of the file and/or the code that created it in the first place.
-
How to parse contents from XML file in Java
Hi All,
I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
How to parse Contents of XML file??
Thanks in advance,
Rajendra.Hi All,
I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
How to parse Contents of XML file??
Thanks in advance,
Rajendra. -
How do I create individual xml files from the parsed data output of a xml file?
I have written a program (DOM Parser) that parses data from a XMl File. I would like to create an individual file with the corresponding name for each set of data parsed from the xml document. If the parsed output is Single, Double, Triple, I would like to create an individual xml file (Single.xml, Double.xml, Triple.xml)with those corresponding names. How do I create the xml files and give each file the name of my parsed data output? Thanks in advance for your help.
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class MyDomParser {
public static void main(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("ENtemplate.xml");
doc.normalize();
NodeList rootNodes = doc.getElementsByTagName("templates");
Node rootNode = rootNodes.item(0);
Element rootElement = (Element) rootNode;
NodeList templateList = rootElement.getElementsByTagName("template");
for(int i=0; i < templateList.getLength(); i++) {
Node theTemplate = templateList.item(i);
Element templateElement = (Element) theTemplate;
System.out.println("Template" + ": " +templateElement.getAttribute("name")+ ".xml");
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();Ive posted the new code but now I'm getting a FileAlreadyExistException error. How do I handle this exception error correctly in my code?
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class MyDomParser {
public static void main(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("ENtemplate.xml");
doc.normalize();
NodeList rootNodes = doc.getElementsByTagName("templates");
Node rootNode = rootNodes.item(0);
Element rootElement = (Element) rootNode;
NodeList templateList = rootElement.getElementsByTagName("template");
for(int i=0; i < templateList.getLength(); i++) {
Node theTemplate = templateList.item(i);
Element templateElement = (Element) theTemplate;
System.out.println(templateElement.getAttribute("name")+ ".xml");
for(int i=0; i < templateList.getLength(); i++) {
Node theTemplate = templateList.item(i);
Element templateElement = (Element) theTemplate;
String fileName = templateElement.getAttribute("name") + ".xml";
Files.createFile(Paths.get(fileName));
System.out.println("File" + ":" + fileName + ".xml created");
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); -
How can i read local excel file into internal table in webdynpro for abap a
Could someone tell me how How can i read local excel file into an internal table in webdynpro for abap application.
thank u for your replyDeep,
File manuplations...............................
1. At the presentation level:
->GUI_UPLOAD
->GUI_DOWNLOAD
->CL_GUI_FRONTEND
2. At the application server level:
->OPEN DATASET : open a file in the application server for reading or writing.
->READ DATASET : used to read from a file on the application server that has been opened for reading
-> TRANSFER DATASET : writing data to a file.
-> CLOSE DATASET : closes the file
-> DELETE DATASET : delete file
If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
call function 'GUI_UPLOAD'
exporting
filename = p_file
filetype = 'ASC'
has_field_separator = '#'
tables
data_tab = t_data
p_file : excel file path.
t_data : internal table
<b>reward points if useful.</b>
regards,
Vinod Samuel. -
How to config the web.xml file, when I use Richfaces + RI 1.2?
Hi there:
I want to use Richfaces + RI 1.2 to build a project. I don`t know how to config the web.xml file.
By the way, my web server is Tomcat 6.0, my JDK's version is 6u6. I don`t want to use the facelets.
thanks.
lxmjust add this before *</web-app>*
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping> -
Does anyone know if there is a way to write data to a local xml file using the Connection refresh Button??
Hi there Glenn,
That's tricky...
Are you using SP1? You need to have at least SP1.
The XLFs were generated with an internal build newer than SP1, but they should still work in earlier builds.
If you changed the HTML file, that might be the cause. The SWF references in the HTML file must be exact.
Also, the range names must match as defined in the XLF/SWF. The bolded lines following should match. It's easiest if they all use the SWF name.
else if (hasRequestedVersion) {
// if we've detected an acceptable version
// embed the Flash Content SWF when all tests are passed
AC_FL_RunContent(
"src", "consumer",
"width", "380",
"height", "308",
"align", "middle",
"id", "consumer",
"quality", "high",
"bgcolor", "#ffffff",
"name", "consumer",
+"flashvars",'historyUrl=history.htm%3F&lconid=' + lc_id + '',+
"allowScriptAccess","always",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be placed here. '
'This content requires the Adobe Flash Player. '
'<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
document.write(alternateContent); // insert non-flash content
// -->
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="consumer" width="380" height="308"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="consumer.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="always" />
<embed src="consumer.swf" quality="high" bgcolor="#ffffff"
width="380" height="308" name="consumer" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed> -
How to extract data from XML file with JavaScript
HI All
I am new to this group.
Can anybody help me regarding XML.
I want to know How to extract data from XML file with JavaScript.
And also how to use API for XML
regards
NagarajuThis is a Java forum.
JavaScript is something entirely different than Java, even though the names are similar.
Try another website with forums about JavaScript.
For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3
Maybe you are looking for
-
Parent key is not found , SQLException
Hello, I have simple master -details relations , those are used ion the same page of the application, in the normal situation, upon commit first INSERT for the master table is executed, then Insert of the details tables, but in only one scenario an I
-
Designjet 130. The printer prints not the right colors
Ru: Принтер печатает не правильные цвета: жёлтый - отсутствует (отображается белым), красный - печатает розовый, зелёный - печатает голубой. Калибровка не помогает. Все картриджи полны краски. En: The printer prints not the right colors : yellow - n
-
HT5467 Can't turn off Location Services
I want to turn off location services but all the on/off buttons are greyed out. Why is this?
-
Hello guys! I'm looking forward to a solution to a little problem I have. I'm developing with Oracle Portal an intranet. I want to make a tab where each user can put there their documents. The problem is that I want a portal much better than the one
-
Where are the files stored when creating a package using CCPLauncher????
I just bought Captivate 7 for Windows. I need help in installing the software. I downloaded the CCPLauncher.exe and specified all the options to build a package, however, I ran out of disk space on the drive. So I quit the CCPLauncher.exe and want to