• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Parsing XML

New Here ,
Jun 05, 2007 Jun 05, 2007

Copy link to clipboard

Copied

I need some help with parsing out some data within a XML document. I need to be able to convert the code list below.

<----current code----->
<id>CHAPTER 1 ADMINISTRATION</id>
<title>CHAPTER 1 ADMINISTRATION</title>
<----current code----->

into

<----output after parsing----->
<id>CHAPTER 1</id>
<title>ADMINISTRATION</title>
<----output after parsing----->

Any help would be greatly appreciated.


Text
TOPICS
Advanced techniques

Views

407

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 06, 2007 Jun 06, 2007

Copy link to clipboard

Copied

LATEST
Seems like a job for regular expressions!

<cfsavecontent variable="myXML">
<id>CHAPTER 1 ADMINISTRATION</id>
<title>CHAPTER 1 ADMINISTRATION</title>
</cfsavecontent>

<cfset rePattern = "(<id>)(CHAPTER [0-9]+)( ?[^<]+)(</id>)(#chr(13)##chr(10)#)(<title>)(CHAPTER [0-9]+ ?)([^<]+)(</title>)">

<cfoutput>
#reReplaceNoCase(myXML, rePattern, "\1\2\4\5\6\8\9", "all")#
</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation