Anonymous_User Absent Member.
Absent Member.
530 views

Parsing XML from Oracle Database field type XMLTYPE


Hi guys,
Firstly a little helper, if anyone is trying to read an table that
contains the data type XMLTYPE, then the query you specify in Sentinel
wont read the field directly, i.e. following wont work:

> select xmlfield from tablename;


To resolve this you can use the following method:

> select xmlfield.getCLOBval from tablename;


Atleast it worked for me 🙂

But now on to the second part, how to parse the XML received. Examples
available on the net are mostly related to parsing XML on browsers
therefore the use of "window.XMLHttpRequest()" or
"ActiveXObject(“Microsoft.XMLDOM”)", i.e. something like the following
code:

>
> if (window.XMLHttpRequest)
> {
> xmlDoc=new window.XMLHttpRequest();
> xmlDoc.open(“GET”,XMLname,false);
> xmlDoc.send(“”);
> return xmlDoc.responseXML;
> }
> // IE 5 and IE 6
> else if (ActiveXObject(“Microsoft.XMLDOM”))
> {
> xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);
> xmlDoc.async=false;
> xmlDoc.load(XMLname);
> return xmlDoc;
> }
>


Please let me know if there is any Sentinel specific XML parsing logic
or objects available, if so then any documentation to it would help.

Regards,
Saqib


--
saqibmabbasi
------------------------------------------------------------------------
saqibmabbasi's Profile: https://forums.netiq.com/member.php?userid=2399
View this thread: https://forums.netiq.com/showthread.php?t=44992

0 Likes
4 Replies
Anonymous_User Absent Member.
Absent Member.

Re: Parsing XML from Oracle Database field type XMLTYPE

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The Rhino environment is a Java-based JavaScript engine. One of the
perks of that is you have full access to the Java Runtime Environment,
and anything you add to it. Any classes that come with the Sun JRE
(specifically the 1.6.0_xx version that ships with Sentinel) should be
available. As I recall there are a bunch of XML parsers from there.

Perhaps try the DocumentBuilder class, the Document class, and the other
starters here:

http://www.java-samples.com/showtutorial.php?tutorialid=152

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQgOEOAAoJEF+XTK08PnB5flYP/0tlIJ6cr/02X0hFQrZJ/38U
9AatU5ZxSKq3J03VSXAiLh2pg51RDQVTMh86FSbbNYHyGOZc7EY4dr/MRRkSzz9V
/2j4X2vdjh+dmC+6AicZ5iaUNna5NMSR9C71FXRGEdDJJjgL1MrdkI2c6DluLeJh
1DuZWxO3Y/qenyzPCtMF5gEds9AEATZjHdKUqA3dB3c8a0OZyI1KGTu33vDslpv/
jhkvnBu4L9lQaQne5aRWyJkRYh0RM8seq0LqnzcYUqTd2WkUezR9bp9CILK7DJy4
zHw1eva+MjsQeok67QQS9jbbbe1S+0t2Zgt86RQIJrkwl9jRIlNEV0lG1ygQAgob
b2g7gNq2QL0R7QAIwtaXwukZoR7cINnMZYwP40caTD26qFBtvFjGaiiq5fi4FCt+
QapjzSwFMe7EhF3cgDOmwmugjirzhkjKP4Vrsc9i5/AJtnnyoxrtijuzdUoduY8d
tJE7J/Q3G1Q2z2MfVI7fMLZQ0oAVrrxCs0mT1y4h8EpyUOEUVtAXLhuxA3zGQ4W4
k9X283f6HYy0TFYeUdn5FWHYc0RDl96kNNkbwLOmX47QGP/8dU3L1diMmxoA7PK1
1QND8O1M1NrvzBC2ExtQk8TbusfiJsWpIjddvFwu6sTecpWmsCjhABbhuiQq9E//
gIr9Ro7mZc2dn94wbRxs
=/cET
-----END PGP SIGNATURE-----
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Parsing XML from Oracle Database field type XMLTYPE


Hi ab,
Thanks, is the Rhino environment shipped and configured with Sentinel ?

Because I checked and it isn't shipped with Java 1.6.

One more question regarding fields of the event.

Can we use any name of the variables and then assign map those variable
names to Sentinel event fields?
for example if I want to change the Event name then can i use a variable
named "EventName" and then map it to Event Name in Rec2Evt.map or we
have to use the "evt" variable name.

If we can't change the variable name then I dont see the point of
"Rec2Evt.map". Further, from where can we get the list of variables to
which we should assign our details. Because, when I used different
variable names they didn't show on the Events on browser.

Regards,
Saqib.


--
saqibmabbasi
------------------------------------------------------------------------
saqibmabbasi's Profile: https://forums.netiq.com/member.php?userid=2399
View this thread: https://forums.netiq.com/showthread.php?t=44992

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Parsing XML from Oracle Database field type XMLTYPE

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

A couple things:

First, if you have not seen it, please check out the website for the
SDK: http://www.novell.com/developer/develop_to_sentinel.html

Second, questions of this detail probably belong in the SDK forum where
people interested in development for Sentinel reside:
https://forums.netiq.com/forumdisplay.php?75-DEVELOPERS-Plug-in-SDK

Finally, yes Rhino is shipped as part of Sentinel. You can use its JAR
file to run a "shell" on your own for testing, or you can develop with
the SDK and do your testing within Sentinel for more complete testing
(testing without Sentinel won't include the full environment like
testing with Sentinel will, but without is easier and good for basic
syntactic/etc. stuff).

You can use whatever variable names you want as far as I know, within
the limits of the language. Maps handle the rest, if you have set them
up for use. Also, just setting a random variable as below:

var randomVar = 42;

won't be enough; the variable should be an instance variable of the
event object, so you'll probably be doing something like 'this.randomVar
= 42;' or 'e.randomVar = 42;' or something similar. For more on this,
see the SDK and ask in its forum.

Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQIcBAEBAgAGBQJQgTwnAAoJEF+XTK08PnB5xfcP/iaB8Wqel3SAE41HONeOxr24
p4OO3TBim+bXdrTCPFhJ7qo1vS1b/FHv8wUpz+aYk+NjP/jujOYOpxd6Y/7vEhtr
jK598SA7s9iUUPbLY6u43wJdjzsIaSWnje60mCfdjI0dP7GkpVReFXkSgWaxeEnn
rhg2TJJ5US/KCdU2KB8fBDQP7fj3G04H94lf8dGJtY4npuUxipbxNSwqizw7uYdr
sJp8+qmQAszQGMYF/v238hdizB0Cehd6/Nldlxklsw6n6HeXGcenY6ZhkwbWQ7bC
66cOHckWKgbhcHt7EQwN+Sr74s8+S1WLlES6ZyDvSL2mDlft/7akC/+CNa1d63Oq
YTt26ROVmW4S71BYgCWWLDH6BlHnHjLREBqzRMY+d0hSB6ZiF+OLitpcrL7muq5/
JcFJlJKz1U/Jbm+tDlmd7VaZuicL+OIZh5qjcE+koO+jqTgcmy5XEeLMklrJhbPf
s3jigCtJ3551ORPKHfTURF1QVC+ksKjMil37Eo3F6dtdRqmE98Nbh009u8YiAHxI
81PhJqKOsBgN0Max1pOISHRw8kWwp/agvpxGgP1cYl3xTJQg9LQK7ul2ObIWO6S7
A3ZM0WhSZFYTm9A9PtK7ZGFNMQjCZCgFr3+pFbXdwBwb0v+mBAe5v43GzTpBE7Jl
EwQJJZH4VJtNisut+10i
=e+4J
-----END PGP SIGNATURE-----
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Parsing XML from Oracle Database field type XMLTYPE

Hi Saqib,

>>> On 19.10.2012 at 04:04,

saqibmabbasi<saqibmabbasi@no-mx.forums.netiq.com>
wrote:

> Hi guys,
> Firstly a little helper, if anyone is trying to read an table that
> contains the data type XMLTYPE, then the query you specify in Sentinel
> wont read the field directly, i.e. following wont work:
>
>> select xmlfield from tablename;

>
> To resolve this you can use the following method:
>
>> select xmlfield.getCLOBval from tablename;

>
> Atleast it worked for me 🙂
>
> But now on to the second part, how to parse the XML received.


You can use E4X in your collector, e.g.:
# construct an XML object
this.xml = new XML(this.s_RXBufferString);
# use XPATH to access elements
this.eventid = this.xml.System.EventID;

See also the Cisco Intrusion Prevention Collector.

Norbert

> Examples
> available on the net are mostly related to parsing XML on browsers
> therefore the use of "window.XMLHttpRequest()" or
> "ActiveXObject(“Microsoft.XMLDOM”)", i.e. something like the following
> code:
>
>>
>> if (window.XMLHttpRequest)
>> {
>> xmlDoc=new window.XMLHttpRequest();
>> xmlDoc.open(“GET”,XMLname,false);
>> xmlDoc.send(*);
>> return xmlDoc.responseXML;
>> }
>> // IE 5 and IE 6
>> else if (ActiveXObject(“Microsoft.XMLDOM”))
>> {
>> xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”);
>> xmlDoc.async=false;
>> xmlDoc.load(XMLname);
>> return xmlDoc;
>> }
>>

>
> Please let me know if there is any Sentinel specific XML parsing logic
> or objects available, if so then any documentation to it would help.
>
> Regards,
> Saqib


0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.