Home > Enterprise >  OpenEdge 11.7 XML change
OpenEdge 11.7 XML change

Time:06-30

What is the simplest method of reading in an XML and changing a single field value?

Basically an XML exists with prices using commas "," instead or periods ".", so I want to rewrite it exactly as is but replacing the commas in the relevant fields.

CodePudding user response:

The simplest, ugliest, most error-prone way is to read the XML doc into a LONGCHAR variable and use the REPLACE() statement.

If the XML can be read into a ProDataSet, then READ-XML and WRITE-XML are your friends. READ, find all the records that need changing, then WRITE.

The better way is to use the SAX parser to identify the elements whose values need to change, and write the changed values using the SAX writer. ALl other values can simply be written as-is.

You can use the SaxReader class in OE is an example of a reader. The DecisionService uses this reader.

The PayloadBuilder class has an example of the writer.

CodePudding user response:

If your only goal is to transform your XML, you can use XSLT. You are not the first person to run into issues with incorrect decimal representations. See for example:

  • Related