Parsing an xml that is stored in a sql column
Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21275
Printed Date: 28 Apr 2024 at 4:34am
Topic: Parsing an xml that is stored in a sql column
Posted By: scott.morrison
Subject: Parsing an xml that is stored in a sql column
Date Posted: 13 Jan 2015 at 2:00pm
Due to the nature of the content stored within my db, I cant reveal a few things, but I need to parse a xml. I looks like below (you can see where i censored). I am looking for the value within "current=___" which is within the first (highest) level of the xml code. and I need to pull it from each record in the database in relation to its unique ID. column 1 is unique id and column two is the xml column. anyone have any suggestions?? I'd appreciate any help.
<manifest xmlns:ver="a url i can't reveal" current=" the data i am looking for" ID=" a number i cant reveal and is useless" documenttype="a type i cant reveal" censoredCount="1">
<phase id= blah blah>
somemore sub sets of data
</phase>
<phase id= blah blah>
more sub sets of data
</phase>
</manifest>
------------- V/R
Scott
|
Replies:
Posted By: lockwelle
Date Posted: 16 Jan 2015 at 5:06am
are you passing the data as xml to the report, or are you getting xml from a field in the database?
if the former, just set the datasource to ado and cr will parse.
if the later, I would probably split using <, then look at the first array element for the word 'current' and grab everything after the =. Then I would probably split again on ", and just take the 1st data element..or 2nd, depends on how CR numbers the array elements.
HTH
|
Posted By: scott.morrison
Date Posted: 16 Jan 2015 at 5:08am
I am getting the xml from a a field in the DB. I am not as familiar with parsing in crystal. Is there a way parse directly from that field?
------------- V/R
Scott
|
Posted By: lockwelle
Date Posted: 16 Jan 2015 at 5:10am
I don't think so. CR may have that ability, but I doubt. If you are storing text in a field, CR will see it as a string, so you would need to parse it that way.
at least that is my belief
|
|