- TIBCO BusinessEvents®
- Standard
- Event

# Event.createEventFromXML()

## Signature

`Event createEventFromXML (String uri, String xml)`

## Domain

ACTION, BUI

## Description

This function returns an event instance using the `xml` . The XML String should adhere to the XSD schema corresponding to the event definition.
If it is desired to strip the whitespace from source XML then set the property java.property.tibco.be.createEventFromXML.stripwhitespace to true in be-engine.tra, the default value of this property is false.

## Parameters

Name | Type | Description
--- | --- | ---
`uri` | `String` | will use the XML to parse the namespace and create the corresponding event.
`xml` | `String` | XML string to be parsed

## Returns

Type | Description
--- | ---
`Event` |

## Cautions

The following exceptions are thrown when Event.createEventFromXML() is used with wrong arguments to create events from XML.
(1) java.lang.RuntimeException: com.tibco.xml.data.cursor.UndefinedPropertyException: [attributes] is not defined for the node type "document".
(2) java.lang.RuntimeException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 41; The processing instruction target matching "[xX][mM][lL]" is not allowed.

## Example

(1) The second argument is used as shown below.
`Event.createEventFromXML("<ONTOLOGY_PATH_OF_THE_EVENT>", "<EventName><payload>"+xmlpayload+"</payload></EventName>");`
Creating a orderline event from the XML argument as payload.
`Events.OrderlineEvent Orderline = Event.createEventFromXML("/Events/OrderlineEvent", "<OrderlineEvent><payload>" + xmlpayload + "</payload></OrderlineEvent>");`
Note : The XML header tag present in String XML might cause parsing issues. In this case, remove the XML version from the input XML string
Part to remove :<?xml version="1.0" encoding="UTF-8"?>
(2) Pass the event properties and payload XML.
`Event.createEventFromXML("<ONTOLOGY_PATH_OF_THE_EVENT>", "<EventName><property1>123</property1><property2>456</property2><property3>789</property3></EventName>");`
Creating an event by passing the second argument with the event properties XML as shown below.
`Events.TestEve TestProperty = Event.createEventFromXML("/Events/TestEve", "<TestEve><lineId>4</lineId><productId>abc</productId><qty>4</qty></TestEve>");`