![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: RegExps for XML Topic Summary: Created On: 6-Apr-2006 15:52 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: I use MSXML to do all my XML processing and I recommend this approach rather than trying to parse the text yourself. MSXML takes care of escaping special characters automatically and gives you the ability to loop through collections of nodes etc. You can find out more here. | |
![]() |
|
Hi All,
Probably having a bit of Brain fade in regard to using RegExps to get at the information within my variation of xml. What I want to do is store information in a module attribute in XML format (generated by a dialog box) then use that information to create my variant of traceability testing. I am having trouble formatting Regexps to extract the information mostly because "*" and "+" are always greedy and find the last occurrence rather than the first. Thought I would ask if any of you DXL Gurus out there had solved this extremely annoying problem ie formulated a regexp to find the first occurrence not the last. The following is an example of what might be in one of my module level text atttributes "<rec><src>/SomeModule</src><path>/FirstModToTraceThrough#/SecondModToTraceTrough#...</path><attName>AttributeToCreate</attName><atts>lots of information about what to get including many carriage returns etc </atts></rec> <rec> same sort of stuff as above </rec> <rec> </rec> ..." At the moment I frig it by using characters that I hope!! will not appear in the module level attribute and by finding the relevant record first and only querying on that (note the differrent character in the FindRec regexp). This works, but if I extend this to a few more levels as I want to in a differrent variant then I will soon run out of uncommon characters, and I want to do it properly anyway! Regexp FindRec = regexp "<rec>([^~]*)~</rec>" Regexp FindSrc = regexp "<src>([^¬]*)¬</src>" Regexp FindPath =regexp "<path>([^¬]*)¬</path>" Regexp FindAttName= regexp "<attName>([^¬]*)¬</attName>" Regexp FindAttStr= regexp "<atts>([^¬]*)¬</atts>" Regexp FindLink= regexp "<link>([^¬]*)¬</link>" Regexp FindOptions = regexp "<options>([^¬]*)¬</options>" I know there are several other ways to skin this particular cat ie functions (time consuming unless of course someone has some to share ![]() Cheers for any Help/ Observations. ------------------------- Regards, Richard Good |
|
![]() |
|
![]() |
|
The attached code goes through all the data in a buffer full of XML and populates a Skip list with the tag names and tag contents. This is specific to an application of mine, but you shouldn't have to change it much.
Shawn ------------------------- Shawn Stepper shawn.e.stepper@wellsfargo.com |
|
![]() |
|
![]() |
|
The attach code will return the given tag (first position) and it contents :
Greetings, Rony =================== Iftakher Uddin (Rony) Iftakher.Uddin@HOOD-Group.com |
|
![]() |
|
![]() |
|
I use MSXML to do all my XML processing and I recommend this approach rather than trying to parse the text yourself.
MSXML takes care of escaping special characters automatically and gives you the ability to loop through collections of nodes etc. You can find out more here. ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
Yes, thats true and its much faster. To navigate the XML; XPath queries can be used which is a very effcient and powerful way to query.
Greetings, Rony =================== Iftakher Uddin (Rony) Iftakher.Uddin@HOOD-Group.com |
|
![]() |
|
![]() |
|
Tony, Rony, Shawn,
Thanks for the suggestions. Tony: I tried the xml approach, downloaded the SDK/documentation for the MSXML4.dll from microsoft, tried to do myself a little vbs script and a javascript. Failed miserably to get anything working at all despite 2 or 3 hours of trying various things. I'm obviously missing a trick somwhere, do you have some sort of example that uses MSXML and DOORS that'd get me orbiting somwhere round the earth, think I'm out by Pluto at the moment. ------------------------- Regards, Richard Good |
|
![]() |
|
![]() |
|
Cheers for the tip Tony: this technique may be very useful to me
Got over my brain fade and did a nice little example: see below (I have also attached the xml file that goes with the dxl) ------------------------- Regards, Richard Good |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
RegExps for XML
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.