Highlighted
Absent Member.
Absent Member.
2264 views

[archive] C$XML string parsing

[Migrated content. Thread originally posted on 12 February 2008]

We are attempting to use C$XML to parse a string from an external source. The string parsing works fine but we also want to update the XML string to return it to the external application. I can add a child and/or sibling and get a valid return-code/handle. However, as this is performed in memory, I cannot access the string to return it to the external application. The doco for C$XML states that a CXML-WRITE-FILE must be executed to commit any modifications applied using C$XML add or modify functions when performing a PARSE-FILE. Is there an equivalent for PARSE-STRING manipulation? Alterantively, is there a way to access the address of the memory area being referred to by the handle which C$XML references? How can I get the pointer/memory address of an area referred to by a handle? Can I use C$MEMCPY to retrieve that area?

Thanks in advance.

Scott
0 Likes
6 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$XML string parsing

I'm not an expert at C$XML, Marilyn Prince at Acucorp had a great sample program (attached). If my memory is correct you need to write the file before you can replace the file that is on the remote server. I believe the sample has many of the functions you are looking for. You'll need a 7.x version.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$XML string parsing

Thanks,

However, we already have a quite extensive version using C$XML, the issue we have is in using the C$XML-PARSE-STRING as opposes to the FILENAME or OPEN-FILE opcodes. As far as I know we cannot get access to the parsed XML string (ie if we modify it) until we write the XML out to a file (all be it a temporay file). What I want to know is is there anyway of accessing the memory area that has been allocated by the C$XML routine? Either through windows functions or manipulating the parser handle? Or can we trick the C$XML write routine to do something else.

I would like to know this before I go down the track of using MSXML6.DLL directly to create an object in the cobol program.

Regards
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$XML string parsing

This is not possible. The structure that holds the XML tree is not a single block of memory, so C$MEMCPY is right out as a possibility. It would be considered an enhancement request to implement SAVE-STRING (say), equivalent to WRITE-FILE.

Also, the user may want to consider XML GENERATE, though a COBOL group structure is required to use this.

Finally, using STRING, the user could create a string which has all of the XML data, just by going through the elements, attributes and data and appending it to a large data string. But that requires coding.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$XML string parsing

thanks for that, so at the moment what you are saying is that in order to process an XML string (this we can do) we would then either have to write this out to a temporary file (by the way how do we get this back into a string?) or we could run throug a loop extracting each element and construct it in a new string. The XML string is comming from a VB Application via the COM object (ACUGT.EXE), we are validating the contents and remapping certain fields and values in this XML string resulting in a modified XML string which we will pass onto the next program as a string for processing. Essentialy an XML transformation module. Any Ideas?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$XML string parsing

As suggested, your best option is probably to extract each element and build the string manually using the STRING verb, then pass this to the VB app.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] C$XML string parsing

Unfortunately what we have done is rewrite the C$XML routine and usr the MSXML object directly reproducing the C$XML functions plus our own functions ie [rootnode].xml which returns the entire tree as a string.

Thanks
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.