Javatpoint Logo
Javatpoint Logo

GWT XML

GWT XML (eXtensible Markup Language) uses custom tags to describe data and encode the data into plain text. It is more flexible and easy to work.

Module XML Format

Modules are defined in XML files whose extension should be .gwt.xml. It is located in the root directory of the project package. Following is the code for using standard project structure:


Parsing XML

To parse the XML text we have to first parse the raw XML text into XMl DOM structure. DOM structure helps in navigation of the data. XML parser is located under XMLParser class. XMLParser class consists of parse(String) static method which is called to parse the XML and return a Document object.

To handle an error occurred during parsing (for example, if the XML is not well-formed), then XMLParser will throw a DOMException. If parsing succeeds, the Document object we receive represents the XML document in memory.

It would create following nodes on successful parsing:

  • Element - represents DOM elements, which are specified by tags in
    XML: <someElement></someElement>.
  • Text - represents the text between the opening and closing tag of an
    element: <someElement>Here is some text.</someElement>.
  • Comment - represents an XML comment: <!-- notes about this data -->.
  • Attr - represents an attribute of an element: <someElement myAttribute="123" />.

Implementation

Below is the XML code that contains email message:

Below code is for extracting information from xml:

GWT XML Constructor

Constructor Description
XMLTools() It constructs different tools option.

GWT XML Common Methods

Method Description
disableIEXMLHackaround() It disables an Internet Explorer-specific work around for the MSXML bug that the 'xml' namespace prefix cannot be explicitly declared.
loadWSDL(String wsdlURL, WSDLLoadCallback callback) It loads a WSDL file and create an instance of WebService that allows invoking operations and binding DataSources to web service operations.
loadWSDL(String wsdlURL, WSDLLoadCallback callback, RPCRequest requestProperties) It loads a WSDL file and create an instance of WebService that allows invoking operations and binding DataSources to web service operations.
loadWSDL(String wsdlURL, WSDLLoadCallback callback, RPCRequest requestProperties, boolean autoLoadImports) It loads a WSDL file and create an instance of WebService that allows invoking operations and binding DataSources to web service operations.
loadXMLSchema(String schemaURL, XSDLoadCallback callback) It loads an XML file containing XML schema definitions and create DataSource and SimpleType objects to represent the schema.
loadXMLSchema(String schemaURL, XSDLoadCallback callback, RPCRequest requestProperties) It loads an XML file containing XML schema definitions and create DataSource and SimpleType objects to represent the schema.
nativeXMLAvailable() It returns true if the current browser exposes an XML parser that can be used for Smart GWT XML operations like web service bindings and XML processing.
selectNodes(Object element, String expression) It retrieves a set of nodes from an XML element or document based on an XPath expression.
selectNodes(Object element, String expression, Map namespaces) It retrieves a set of nodes from an XML element or document based on an XPath expression.
toJS(Object elements) It translates an XML fragment to JavaScript collections.

GWT XML Uploading

In this section we would be creating an upload panel with GWT File upload and Form Panel widgets. It allows user to upload zip files to the server.

Frontend Design

To store the information through xml we design the frontend from two panels which are UploadPanel, and DataStorePanel.

DataStorePanel.ui.xml

UploadPanel

In this widget we create form to upload the file and button to clear the symbol list.

UploadPanel.ui.xml

Upload.java

Output:

GWT Xml
Next TopicGWT Charts




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA