1 Reply Latest reply on Jun 6, 2007 9:30 AM by insuractive

    Parsing XML

    webhead_1
      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
        • 1. Re: Parsing XML
          insuractive Level 3
          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>