Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: parsing any kind of XML file
Topic Summary:
Created On: 12-Aug-2008 20:55
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 12-Aug-2008 20:55
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

Hi All,

I'd like to know how you'd write a DXL library/function that parses an XML file (regardless of the number of elements and levels of nesting). You should include this library so that when you parse an actual XML file, you just access the library using methods like getElement() that'll return the value of the tag you are parsing.

For example, if your XML looks like below:
<Root>
<Test>......<^ST8;...</Test>
<..>.....<..>
<..>....<..>
......
.......
....
</Root>

Then, the function should return the value of "Test" when you access it using getElement() or something like that. The problem here is you don't know the number of tags in the XML, the levels of nesting and the data type.

The idea of doing this is to come up with a generic XML parser, that will parse any kind of XML file as input.

Thanks.
Report this to a Moderator Report this to a Moderator
 13-Aug-2008 09:46
User is offline View Users Profile Print this message


Anders Vestlin

Posts: 11
Joined: 30-Aug-2007

You may look into the undocumented functions below:
string getElementText_(DOM_Element_)
string getElementName_(DOM_Element_)
string setStringAttribute_(DOM_Element_, string, string)
string getStringAttribute_(DOM_Element_, string)
bool hasChildElements_(DOM_Element_)
bool hasAttribute_(DOM_Element_, string)
DOM_Element_ getDocumentElement_(DOM_Document_)
DOM_Document_ getDocumentBuffer_(DOM_Document_, Buffer&)
DOM_Document_ parseXMLBuffer_(Buffer)
DOM_Document_ parseXMLString_(string)

Se code for an example
Report this to a Moderator Report this to a Moderator
 13-Aug-2008 20:30
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

I tried running the example code after making some modifications to it. I got the following error:

-R-E- DXL: <Line:25> cannot open file (C:\Documents and Settings\avembar\My Documents\test2objs.xml) for reading (Too many open files)
Backtrace:
<Line:52>
<Line:69>
-I- DXL: execution halted

I've attached the code and the XML file that's used as input. Could you please let me know what's wrong?

Thank You.
Report this to a Moderator Report this to a Moderator
 13-Aug-2008 23:46
User is offline View Users Profile Print this message


Matthew Thomas

Posts: 15
Joined: 14-Feb-2008

Hi there Anant
Interesting stuff, but to comment intelligently it'll help if you could outline what you are trying to achieve, as there can be > 1 * 2_skin_a_cat().
i.e. what purpose are you fulfilling by parsing the XML file?
Report this to a Moderator Report this to a Moderator
 14-Aug-2008 07:46
User is offline View Users Profile Print this message


Anders Vestlin

Posts: 11
Joined: 30-Aug-2007

Your modification of the code has made the function to call it-self, i.e recursion. That's why you get
(Too many open files)
. Thera is a call to funcImportResult(domObject, m) in the original which is a different function I didn't supply. Here it is:
Report this to a Moderator Report this to a Moderator
 26-Aug-2008 14:53
User is offline View Users Profile Print this message


Marco Gomes

Posts: 11
Joined: 4-Sep-2007

A little library to handle XML files in DOORS (tested in v7.1)

Hope this can help or can be updated by others users.

xmlLib.dxl
xmlLib.dxl  (17 KB)

Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.