PxPlus User Forum

Twitter Twitter Twitter

Author Topic: White space in XML is consolidated  (Read 192 times)

Loren Doornek

  • Silver Member
  • ***
  • Posts: 21
    • View Profile
White space in XML is consolidated
« on: March 05, 2020, 09:10:25 AM »
In parsing xml using the XML() functionality, I've found that multiple spaces are consolidated into a single space, as shown in the following example, where the multiple spaces result in the single space within the string after using the XML function:

-}xml$="abc   123",ofst=0;x$=xml(next from xml$,ind=ofst,key=name$);?x$
abc 123

Researching this, I see that it is fairly standard for XML parsers to consolidate white space.  But, in some cases, we need to keep that white space (eg: a user entered a value that comes through the xml, and we need to match based on that value). 

Is there any way to tell the XML() command to *NOT* consolidate the white space?

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3291
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: White space in XML is consolidated
« Reply #1 on: March 05, 2020, 09:40:56 AM »
Generally in XML if you want to maintain white space or other special characters you use CDATA.

For Example:

->xml$="<text><![CDATA[lots  of   spaces]]></text>"
->x$=xml(next from xml$,ind=ofst,key=name$);?x$
lots  of   spaces
->?name$
text$



Loren Doornek

  • Silver Member
  • ***
  • Posts: 21
    • View Profile
Re: White space in XML is consolidated
« Reply #2 on: March 09, 2020, 10:16:00 AM »
Thanks, Mike!