Operations Orchestration Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to parse XML?

Highlighted
AlexGg
Collector

What is the best way to parse XML?

I am wondering if OO has some easy way to parse simple XML file, or string?

E.g.

<tops>
 <items>
  <item>
   <buser>sankesh</buser>
   <naddr>tutall</naddr>
  </item>
 </items>
</tops>
All I need is get result like:

buser=sankesh

naddr=tutall

 

I know I can strip all content by something, but looking for ready way.

Thanks.

 

6 REPLIES
Lucian-Revnic
Regular Collector

Re: What is the best way to parse XML?

Hello Alex,

 

Have you tried to use the XPath Evaluator or XPath Query operations?

Other useful XML operations are located under XML Processing folder.

 

Hope it helps,

Lucian

AlexGg
Collector

Re: What is the best way to parse XML?

Oh, Thanks
ntt00015
Frequent Visitor

Re: What is the best way to parse XML?

Hi,

 

If there is any namespaces in your xml, you can not parse your xml string. I am not sure but OO9.02(with content patches 9_00_06) uses XPATH 1.0 version for XPATH evaluator. If you want to parse XML with namescapes first you should remove the namespaces from xml string using regular expression.

 

Regards. 

AlexGg
Collector

Re: What is the best way to parse XML?

Thanks. So, thus to parse entire XML I have to know the structure of it, right?

How about get it parsed without such knowledge?

Other words: if XML is some config file of something, is it possible at all to get all variables and its values?

ntt00015
Frequent Visitor

Re: What is the best way to parse XML?

It does not matter if it's a config file or a return string from  webservice. You can get all values if you know the structure(I mean paths).

In your example you didn't have any XMLnamespaces. So you don't have to bother yourself about it. But if the config file have the XMLnamespaces firstly you should parse it with regular expressions(via perl/javascript) and then use the output string in OO XML Operations(Thats how I do in my xml operations).

 

I am waiting for the new patch for JSON format, so hopefully I will be parsing any XML string in OO without using workarounds.

AlexGg
Collector

Re: What is the best way to parse XML?

Thanks! Sounds good to me too now.

//Add this to "OnDomLoad" event