How to create an XML Document and convert it into a string? (send through wireless network)

Hello

I am now able to post data to a web server by using Blackberry JDE (medical use).

Now, instead of display the plain text, I would like to send an XML file.

I am able to do it using this code on a 'normal ': Java application

import java. IO;
Org.w3c.dom import. *;
Import javax.xml.parsers. *;
Javax.xml.transform import. *;
Javax.xml.transform.dom import. *;
Javax.xml.transform.stream import. *;

public class {XML
Public Shared Sub main (String [] args) {}
try {}
DocumentBuilderFactory plant = DocumentBuilderFactory.newInstance ();
DocumentBuilder builder = factory.newDocumentBuilder ();
Doc document = builder.newDocument ();
           
Root element = doc.createElement ("root");
doc.appendChild (root);
           
Child element = doc.createElement ("child");
child.setAttribute ("name", "value");
root.appendChild (child);

Add a text element to the child
Text = doc.createTextNode ("text");
child.appendChild (text);

implement a transformer
TRANSFAC TransformerFactory = TransformerFactory.newInstance ();
Transformer trans = transfac.newTransformer ();
trans.setOutputProperty (OutputKeys.OMIT_XML_DECLARATION, 'yes');
trans.setOutputProperty (OutputKeys.INDENT, 'yes');

create the string of the xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult (sw);
DOMSource source = new DOMSource (doc);
TRANS. Transform (source, result);
String xmlString = sw.toString ();
System.out.println (xmlString);
} catch (Exception e) {}
make error management
}
}
}

However, on the Blackberry JDE, many functions is not recognized.

I saw the class DocumentBuilderFactory (net.rim.device.api.xml.parsers.DocumentBuilderFactory), the DocumentBuilder (net.rim.device.api.xml.parsers.DocumentBuilder) class and the interface of Document in the docs of Blackberry Java (4.2.1).

So, I'm able to create an XML Document... but I don't know how to convert to a string?

How can I do this? The TransformerFactory class doesn't seem to exist... and I did not find an alternative yet.

At the present time, here is the code I use to publish data:

String coord = lat + ";" + LNG; post data
con = (HttpConnection) Connector.open (url); Open the connection URL
con.setRequestMethod (HttpConnection.POST); POST method
con.setRequestProperty ("Content-Type", "application/x-www-formulaires-urlencoded");
out = con.openOutputStream (); display the results in a stream
out. Write (Coord.GetBytes ());

responseCode = con.getResponseCode (); Send data and receive the response code
If (responseCode! = HttpConnection.HTTP_OK) {}
System.out.println ("HTTP STATUS CODE: 404"); error
} else {}
System.out.println ("HTTP STATUS CODE: 200"); successful
}
If (con! = null) con. Close; close the connection to the URL

As mentioned, rather than display a string with a delimiter between each value (there will be a lot more than two values finally), I would like to publish an XML.  It will be more "elegant" and easier to parse by my code on the web server.

Maybe I don't have to convert it to a string?

In other words, how can I convert my XML Document to send it via the wireless network?

Thanks for your help!

TransformerFactory does not exist in the BlackBerry API.  As far as I can tell, you need to implement yourself.  You can do this by walking the DOM and the output of channels.  They have an example of the market of the DOM in the XMLDemo, but they view as fields, you just need to write strings.

Tags: BlackBerry Developers

Similar Questions

  • How to: create a blank document and how to make a font available by editin

    Two questions:

    1: how to create a new PDF document? All I see is to create from an existing document or a scanner. If I created something from scratch, I really load an existing PDF, remove and then start my new document? This is as it seems, that is nuts!

    2: I tried to change the text in a document. I have created no not her, but it is open to editing. The font used in the document is "Arial", a very common font that comes with windows. The font is installed and I use it all the time in other Adobe applications. However, when I try to edit a document using this font, I get a message that "the police is not available for editing" and it substitutes random fonts. Then why is it not available, and how to make it available?

    Thank you!

    I use Adobe Acrobat XI Pro with Adobe Creative Cloud 2014 and Windows 7, all v.11.0.10 were also updated.

    I'll add to it. If you're new to Acrobat, it is possible, that you have the wrong end of things. Acrobat is not a good editor or word processor or a design tool; It does not replace your editor or word processor or your design tool. People do not only from the file > New and start putting stuff on the page. It will be limited, slow, frustrating and annoying.

    People continue to put documents in all the tools they have always and use Acrobat to CONVERT to PDF format. If a change is necessary, no matter how trivial, the original is edited and redone the PDF.

    The Acrobat editing tools must be used when the original is lost and backups have been eaten by termites.

    There are specific reasons for wanting to a blank document, but I hope that these tips will put you in a different direction.

  • How can I take a document and convert it to PDF

    I have a receipt which must be sent as a pdf to open by the refund r. How to do this.

    Is it a receipt on paper? Your scanner should be able to save it as a PDF file and then you can attach it.

  • How to duplicate a text element and convert it into paths?

    Hello

    I'm totally stuck. I can't duplicate a selected TextFrame and make an outline of it. I tried "MyChoice.TextFrame.createOutline ()", but he told me that "undefined is not applicable. What I am doing wrong?

    Environment: Illustrator CS4, ExtendScriptToolkit, Javascript.

    Help!

    Moebius

    mySelection var = app.activeDocument.selection;

    for (j = mySelection.length - 1; j > = 0; j-) {}

    Alert (mySelection [j]. TypeName)

    If (.) TypeName mySelection [j] == "TextFrame") {}

    mySelection [j] .createOutline ();

    }

    }

    There are a few things that you mixed like me dun time now to explain, above is a working code (I think that Yes...) ... I'll be back later with an explanation

    see you soon;

  • I created a document in Photoshop CC with URLS and hyperlinks.  I want to take this document and convert it to PDF AND I wan't these URLS and hyperlinks to be clickable.  How do I do that?

    I created a document in Photoshop CC with URLS and hyperlinks.  I want to take this document and convert it to PDF AND I wan't these URLS and hyperlinks to be clickable.  How do I do that?

    It works very well.  Use the screening of high printing quality, but think about what resolution for your graphics card.  In fact if you have higher res images online versions, you can hot link to them from the PDF file.  I used to publish a magazine of the club until a couple of years, and while I've used InDesign, output to PDF format was exactly the same process

    http://www.marlboroughcameraclub.org.nz/photo-news/Arti/photo-news-2013/

    If you want to go one step further, take a look at this example, which uses the SWF to the page turn effect

    http://www.f11magazine.com/current.html

    I assume that your document is a good single page?  Photoshop is a clumsy tool for multi-page documents.

  • How to convert an Indesign document and convert a continuous flow word document

    How to convert an Indesign document and convert a continuous flow word document?

    Thank you so much worked perfectly.

  • Convert flat file to XML document and store it in the Oracle database

    First of all:
    I have a flatfile and created an external table to read this file in Oracle
    Now, I want to create an XML document for each line and insert in the Oracle database, I think as XMLtype.
    Could you please give me some information/steps.

    Second:
    Are there performance issues, because every day, I need to check that the XML document stored in the database against the next file.
    Thank you.

    I won't tell it not in the same words that Marco used, but your solution is impassable and an invitation for bad things to happen.

    Wait miserable performance, and you will not be disappointed.

    The concept of total flexibility works up a code that you depend on has no idea what to do with what is playback.
    Will happen to enough short term and is roughly the equivalent of the absurdity of Java to be independent of the database.

    I would recommend you take the concept and consider, with your data volumes, something more likely to succeed.

  • When I print a MS Word document my printer prints symbols but when I create a new document and try to print the new document of his impression.

    * Original title: printer print only symbols

    Hello world

    When I print a MS Word document my printer prints symbols but when I create a new document and try to print the new document of his impression. If my old document is damaged to corrupt so how do I fix it

    Old documents are probably corrupt. Check out these links:

    How to troubleshoot print failures in Word: https://support.microsoft.com/en-us/kb/826845

    How to troubleshoot printing problems in Word: https://support.microsoft.com/en-us/kb/826862

    Troubleshooting damaged in Word documents: https://support.microsoft.com/en-us/kb/918429

    And this announcement in Office/Word groups is a better idea. This may very well be a FAQ here.

  • using a hp 6500 - how to scan several image documents and keep them in a single image file

    using a hp 6500 - how to scan several image documents and keep them in a single image file instead of hafving to create a separate file for each page?

    http://h30434.www3.HP.com/T5/scanning-faxing-and-copying/HP-OfficeJet-6500-scan-multiple-pages-into-one-PDF-file/TD-p/252650

    This previous thread should help you.

  • How to generate a Word document and a PDF file of help files?

    Hello

    I'm new to RoboHelp HTML and uses version 8.  I've updated some help files, and now I want to generate the output.  Here are my questions / or the process that I used:

    • To compile the help, I clicked on generate a main page layout.  Is this correct?  I noticed that the stamp on the xpj file has not changed.  The date is still many months.  (Why is this?  Must show a recent update date?)  However, the files that I've updated reflect the dates when I did the updates.  It comes to files art, a high hydrostatic pressure and htm, js, ldb, pss, DPC files.
    • To generate a pdf file, I clicked on Generate PDF.  I was not able to generate the PDF file first, but then I enabled macros in Word 2007 (Trust Center settings > enable all macros.. .and clicked on the checkbox, approved access to the VBA project object model) and you click on Generate the PDF.  At the end of the generation, I got this error in Word: Microsoft Office Word has encountered a problem and needs to close.  We are sorry for the inconvenience.  The news that you were working may be lost.  Word can try to recover it for you.  I closed the Word and dialog box generated several blank documents.  Microsoft Office Diagnostics was performed and found a problem and fixes it.  Despite the error message was generated a pdf file.  (If you could give me any idea on why I got error messages, which could be useful to know).
    • How to generate a Word document?

    Thank you!

    Erin

    Welcome to the forum.

    I would suggest a different workflow.

    When you select generate a main page layout, RoboHelp did this according to the settings in all that is attached to your main layout. Better at least first double-click the page layout so that you see the settings and can make a difference to the way you want. After that, you can use generate a main page layout if you want, but I'd rather go through the layout itself and check the settings.

    The XPJ file changes only when certain things should be recorded in it and it's not every time that you are working on the project. In other words, don't worry about the date of the file.

    Now for the PDF. Again not the best place to start and still better to go of the provision itself. You can try to simply generate a PDF file, but many users prefer to create a Word document and make some changes in that. It can just be put page breaks to improve appearance, it may be more, it's your call. Once the Word document is good, generate the PDF from there.

    You will find the page layouts, that I want to talk in the pod of single Source Layouts. View > pods.

    See www.grainge.org for creating tips and RoboHelp

    @petergrainge

  • How can I delete my documents and get rid of my thinkpad with windows 95?

    How can I delete my documents and get rid of my thinkpad with windows 95?

    If there is anything physically wrong with your computer, you can use Darik Boot and Nuke (DBAN aka) to make a scrub of the security of your HARD drive. Glance to download here.

    This will leave Nothing on the HARD drive. You can take the time to reinstall an operating system, but at the very least, the new operating system should be Win 98SE or higher.

  • Impossible to analyze the xml.aspx contained in the main.js.Iam get the following error"could not obtain XML document, and the connection has failed: status 500

    Impossible to analyze the xml.aspx contained in the main.js.Iam get the following error"could not obtain XML document, and the connection has failed: status 500

    My main.js resembles

    xmlDataSource var = {}
     
    URL: 'dcds. - symbianxml.aspx", etc. (sample).
     
    init: function() {}
    URL, successful reminder, the reminder of failure
    This.Connect (this.) (URL, this.responseHandler, this.failureHandler);
    },
     
    /**
    * Analyzes the XML document in an array of JS objects
    @param xmlDoc XML Document
    * @returns {table} array of objects of the device
    */
    parseResponse: {function (xmlDoc)}
        
    var chElements = xmlDoc.getElementsByTagName ("channel");
       
    channels of var = [];
      
    Console.log (chElements.Length);
      
    for (var i = 0; i)< chelements.length;="">
        
    var channel = {};
       
    for (var j = 0; j)< chelements[i].childnodes.length;="">
        
    var node = Sublst.ChildNodes(1).ChildNodes(0) chElements [i] [j];
                
    If (node.nodeType! = 1) {//not an element node}
    continue;
    }
           
    Channel [node. TagName] = node.textContent;
    }
       
    Channels.push (Channel);
    }
    Console.log (Channels.Length);
    return the strings;
    },
     
    /**
    Manages the response and displays the data from device web app
    @param xmlDoc
    */
    responseHandler: {function (xmlDoc)}
      
    var channel = this.parseResponse (xmlDoc);
    var markup = "";
       
    for (i = 0; i< channels.length;="">
       
    markup += this.generateHTMLMarkup (i, channels [i]);
    }
    document.getElementById("accordian").innerHTML = mark-up;
    },
     
    /**
    Generates HTML tags to insert in to the DOM Web App.
    * @index i, index of the device
    @param device, device object
    */
    /*
    generateHTMLMarkup: function (i, channel) {}
      
    var str ="";
    "Str += '.


    ' onclick =-"mwl.setGroupTarget ('#accordian ',' #items_" + i + "', 'ui-show ',' ui - hide');" + ".
    "mwl.setGroupTarget ('#accordian ',' item_title_ #" + i + "', 'ui-open', 'ui-farm'); Returns false; \ » > » ;
    "" Str += "" + channel ['name'] + ' ";
    "Str += '.
    ";
    "Str += '.
    ";
    "Str += '.
    "+" id: "+ channel ['id'] +" ' "
    ";
    "Str += '.
    "+" type: "+ channel ['type'] +" ' "
    ";
    "Str += '.
    "+" language: "+ channel ['language'] +" ' "
    ";
    "Str += '.
    «+ "bandwidth:" + "fast" channel + "»»
    ";
    "Str += '.
    "+" cellnapid: "+ channel ["cellnapid"] +". "
    ";
    "Str += '.
    «+ ' link: '+'start the video »»
    ";
    "Str += '.
    ";
    return str;
    },*/
    generateHTMLMarkup: function (i, channel) {}
       
    var str ="";
    "Str += '.
    ";
    str +=  "" +
    "" + channel ['name'] + ""+""
    ";
    "Str += '.
    «+ ' link: '+'start the video »»
    ";
         
    return str;

    },
     
    failureHandler: {function (reason)}
    document.getElementById("accordian").innerHTML = "could not get XML document.
    '+ reason;
    },
     
    /**
    Retrieves a resource XML in the given URL using XMLHttpRequest.
    @param url URL of the XML resource to retrieve
    @param called successCb, in the XML resourece is recovered successfully. Retrieved XML document is passed as an argument.
    @param failCb called, if something goes wrong. Reasons, in text format, is passed as an argument.
    */

    Connect: {function (url, successCb, failCb)
      
    var XMLHTTP = new XMLHttpRequest();
      
    XMLHTTP. Open ("GET", url, true);

    xmlhttp.setRequestHeader("Accept","text/xml,application/xml");
    xmlhttp.setRequestHeader ("Cache-Control", "non-cache");
    xmlhttp.setRequestHeader ("Pragma", "non-cache" "");
      
    var that = this;
    XMLHTTP.onreadystatechange = function() {}
       
    If (xmlhttp.readyState == 4) {}
        
    If (XMLHTTP. Status == 200) {}
         
    {if (!) XMLHTTP.responseXML)}
    try {}
    If server has not responded with good an XML MIME type.
    var domParser = new DOMParser();
    var xmlDoc = domParser.parseFromString(xmlhttp.responseText,"text/xml");
           
    successCb.call (that, xmlDoc);
           
    } catch (e) {}
    failCb.call (, "answer was not in an XML format.");
    }
              
    } else {}
    successCb.call (that, xmlhttp.responseXML);
    }
    } else {}
    failCb.call (this, "connection failed: status"+ xmlhttp.status ");
    }
    }
    };
    XMLHTTP. Send();
    }
    };

    Please see the content in main.js is fully analyzed.

    Forward for the solution to my request all members of the community...

  • How to create the home group and how to connect two computers that are running windows 7. and also Remote Desktop connection!

    Someone help me how to create the home group and how to connect two computers that are running windows 7. and also Remote Desktop connection!
    step by step information!

    Hello

    I suggest you to refer to the links and check if it helps:

    Create a homegroup

    http://Windows.Microsoft.com/en-us/Windows7/create-a-HomeGroup

    Join a homegroup

    http://Windows.Microsoft.com/en-us/Windows7/join-a-HomeGroup

    Setting up a network home

    http://Windows.Microsoft.com/en-us/Windows7/setting-up-a-home-network

    Remote Desktop connection

    http://Windows.Microsoft.com/en-us/Windows7/products/features/Remote-Desktop-connection

    What types of connections remote desktop should I allow?

    http://Windows.Microsoft.com/en-us/Windows7/what-types-of-Remote-Desktop-connections-should-I-allow

    Remote Desktop connection: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/Remote-Desktop-connection-frequently-asked-questions

    Let us know if it helps.

  • How to create user defined groups and users with custom permissions as only open and export in obiee 11 g?

    Hello

    I want to give as open & export to the level of permissions.

    How to create user defined groups and users with custom permissions as only open and export in obiee 11 g?

    For example, if the group permissions, inturn should reflect on the users.

    Please help me.

    Thanks in advance,

    A.Kavya.

    Your question is quite broad and fuzzy then I suggest the security catalog presentation to read documentation: http://docs.oracle.com/middleware/1221/biee/BIESC/mgrgrpsusers.htm#CIHIBJGD

    And I think that you mix you two things which are managed in different places:

    ) an object as read access permissions, write, delete... which control you through the object "Permissions" dialog box

    (b) functional privileges controlled through "Manage privileges" under "Administration".

  • I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows?

    I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows so that I can do the calculations?

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll

Maybe you are looking for

  • lost music on the Cloud

    Hello I lost a few music downloaded from my ITunes Cloud, because my credit card is reneweled, and I have run out of time to send the new number to Apple. Do I have a chance to recover these music? Thanks in advance Kisfalat

  • iPhone 6 w/iOS 9.3 Broken - can bypass security Code/imprint

    After the update my iPhone 6 to iOS 9.3 , you can access the office without entering the security code or thumb impression.I activated of Siri. I asked Siri time when iPhone is in the locked state, Siri tells me that time I click on time, then I pres

  • Voice command for Windows

    Using Windows 7 64 bit, how to find the voice command Windows?

  • HP Pavilion 17z - f100 CTO: Dragon-fur

    Hey Dragon fur - it's brush - 01/09/2015 - HP Pavillion 17z - PC CTO (ENERGY STAR) f-100 I had much trouble contact you - I was - for so now stuck long - stuck in professional sites IT cause me to be recognized by MS & HP as a COMPUTER professional -

  • E-mails were deleted after compacting outlook express

    Original title: cancel the outlook express compacting files after compression it removal of e-mails from 23/02/10 to present After compaction it deleted e-mails from 23/02/10 to present