JTSmith Posted August 20, 2019 Posted August 20, 2019 Having a major crisis lol... I have a script that downloads XML, and then parses it out. Worked fine forever, now it says it can't calculate it because it's over 30,000 characters. Anyone know where to start? Thanks!
comment Posted August 20, 2019 Posted August 20, 2019 Why don't you import the XML directly, using an XSLT stylesheet? I don't see your script (or your XML), but in general parsing XML using Filemaker's calculation engine is highly inadvisable.
JTSmith Posted August 20, 2019 Author Posted August 20, 2019 Hey comment! I will hire someone to do that, at the moment I'm just trying to get it to work like it did for a year, can't figure out what happened.... The part that doesn't work anymore: Set Variable [$XML; Value: CleanApiResponse ($XML)] Set Variable [$StatusCode; Value: GetXMLNode ($XML ; "/Response[1]/Status[1]/Code[1]" )] The problem is the $XML variable is over 30,000 characters so the response is always a "?". My XML has always been in the hunderds of thousands of characters so I'm not sure why this morning it stopped working. Would you be willing to help me? I can pay a retainer, or by the hour, etc. I'm stuck. I have three employees sitting around and I can't solve it (yet).
comment Posted August 20, 2019 Posted August 20, 2019 6 minutes ago, JTSmith said: The problem is the $XML variable is over 30,000 characters so the response is always a "?" That doesn't seem a likely reason. AFAIK, variables are limited only by available memory. The 30k characters limit applies to calculation formulas. -- I sent you a private message.
JTSmith Posted August 20, 2019 Author Posted August 20, 2019 I don't understand it... If I do a parse type calculation on the variable it works, but not the custom function "GetXMLNode". I created a field and put the XML in it. I used Data Viewer to try calculations. If I use GetXMLNode function it says "Field Missing". If I make the XML text less than 30,000 characters, it works. The GetXMLNode uses a function as well, maybe that's why? Not sure why it works for a year and then stops.
JTSmith Posted August 20, 2019 Author Posted August 20, 2019 I created a new solution, just one field "XML". Using DataViewer it still won't evaluate it if the XML is over 30k, so it's got to be a sudden filemaker thing.
Devin Posted August 21, 2019 Posted August 21, 2019 Sounds like a issue with the custom. I’ve never had this issue and parse way over 30k. I use the base element plugin.
JTSmith Posted August 21, 2019 Author Posted August 21, 2019 Hi Devin, it's worked forever, now today it doesn't.
Devin Posted August 21, 2019 Posted August 21, 2019 So if no updates to the system have been done.. and Computer has been restarted and your still having an issue then either the custom or the XML it's self is bad.. Can you go back and parse an older XML that did work? We are kinda blind as we don't have the XML that our trying to parse.
JTSmith Posted August 21, 2019 Author Posted August 21, 2019 I opened an old version of the database, a backup copy, still doesn't work. It's seems as if FM just changed, which doesn't make sense. When I use DataViewer in Debugger, it shows the XML, then for the GetXMLNode set to variable it has a question mark. When I change the variable in DataViewer, it gives an error saying it has to be less than 30,000 characters to change the variable.
comment Posted August 21, 2019 Posted August 21, 2019 (edited) We cannot tell the reason without seeing what GetXMLNode() does. If it uses the Evaluate() function, then it certainly could run against the 30k characters limit. And I am not sure there is a quick fix for that. Edited August 21, 2019 by comment
JTSmith Posted August 21, 2019 Author Posted August 21, 2019 Ok, I think I may have an idea after 14 hours... One of the machines that remote logins was using Pro 18 Advanced and the file was hosted on 16. I am wondering if it's a recursive issue or something. GetXMLNode: Evaluate ( Substitute ( Filter ( XPath ; "/" ) ; "/" ; "ExtractData ( " ) & "\"" & XML & "\"" & Substitute ( XPath ; [ "/" ; ";\"" ] ; [ "[" ; "\";" ] ; [ "]" ; ")" ] ) ) **It used the custom function ExtractData: Let ( [ XML_Length = Length ( XML ) ; Attribute_Length = Length ( Attribute ) ; Get_Instance = If ( IsEmpty ( Instance ) ; 1 ; Instance ) ]; Case( IsEmpty ( XML ) or IsEmpty ( attribute ) or PatternCount ( xml ; "<" & attribute & ">" ) = 0 ; "" ; Middle ( XML ; Position ( XML ; "<" & attribute & ">" ; 1 ; Get_Instance ) + attribute_length + 2 ; xml_length - ( xml_length - Position ( XML ; "</" & attribute & ">" ; 1 ; Get_Instance ) ) - ( Position ( XML ; "<" & attribute & ">" ; 1 ; Get_Instance ) + Attribute_Length + 2 ) ) ) )
comment Posted August 21, 2019 Posted August 21, 2019 (edited) Without getting in too deep, it's easy to see that your GetXMLNode() function builds a formula to be evaluated by the Evaluate() function. - and that the formula includes the entire XML. So if the XML exceeds 30k characters, this will fail. This is just another example of how fragile any attempts to parse XML using text functions are. Edited August 21, 2019 by comment
Recommended Posts
This topic is 1933 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now