Joshua Sharf
Joshua Sharf

Reputation: 11

ColdFusion CF2021 xmlParse(file) returning wddx encoded object

UPDATE: After doing some more poking around, it looks as though the problem has to do with where CF is looking for the DTD file referenced in the XML.

We have the DTDs, but it looks as though CF isn't finding them, so it isn't sure how to parse the XML according to the DTD. I determined this by having it parse XML without any DTD, and it worked as expected and as I wanted - returning a parsed xmlDoc, not a string.

Is there some way of setting the default directory for where CF should look for the DTD specified in the XML?


We're running CF2021, and xmlParse(file), which should return a parsed XML object is instead returning the file contents as a string, inside a wddx encoded object. We have just migrated from a CF2018 server running on a remote hosting service to CF2021 running on an AWS box.

In order to return the XML object we need, I need to run xmlParse on the file, then wddx2cfml on the object, then xmlParse again on the string.

Is there a reason why xmlParse, which should return a parsed XML object, is instead behaving this way?

We pass the system file location to the method. Call it docPath, and it'd look something like g:\appName\xmlFiles\20230125.xml

Then we have, in cfscript: doc = xmlParse(docPath);

When I dump that to a file, I get what I described above. When I change it to the following, I get what want: docFile = xmlParse(docPath); cfwddx(action="wddx2cfml", input="#docFile#", output="xmlString"); xmlDoc = xmlParse(xmlString); But I don't understand why this is necessary, and I'm concerned about having to change it everywhere in the code that we use xmlParse. For the record, this also occurs in tagged CF as well as cfscript, so it's not that.

Upvotes: 1

Views: 210

Answers (1)

Joshua Sharf
Joshua Sharf

Reputation: 11

Putting the dtd files in CF's WEB-INF folder solved the problem. CF was able to match the DTD with the DOCTYPE and properly parse the XML.

Upvotes: 0

Related Questions