Author | Topic: XML Functions | |
---|---|---|
Scott Krise | XML Functions on Wed, 28 Apr 2021 11:18:29 -0400 Hello Everyone, I need to read some incoming XML files and I'm trying to understand the process you need to go through to read and process it using the xbase XML functions. Per the Alaska documentation, Im trying to use the following steps as a guideline. ======================================================================================================================= The ASXML library provides a callback processing parser for XML documents. A generic usage pattern for the parser can be split into the following steps: 1. Open the XML document with the XMLDocOpenFile() function. 2. Register functions to process the tags of interest, i.e. we have to define the action the parser should take for a node in the XML structure. This is done using the XMLDocSetAction() function, which allows us to associate a code block with a particular XML tag. We can set as many actions for a document as we want, as long as there is only one action per node. 3. Start the callback processor using the XMLDocProcess() function. 4. Close the document using the XMLDocClose() function. ======================================================================================================================= Has anyone done this? I've gotten it to the point where I'm opening the file via XmlDocOpenFile with no trouble, now I'm trying to understand the XMLDocSetAction function, and I'm finding the Alaska documentation a little lacking. Can anyone send me a snippet of code using this method that I can use as an example? Or can anyone give me some guidance on how to format the XMLDocSetAction() function? Thanks In Advance. Scott | |
Andreas Gehrs-Pahl | Re: XML Functions on Thu, 29 Apr 2021 21:08:40 -0400 Scott, >I need to read some incoming XML files and I'm trying to understand the >process you need to go through to read and process it using the xbase XML >functions. You can use the Xbase++ ASXML functions or directly XmlSimpleParser(), which creates an object of the XMLNode class, but in my experience, using the (free) Chilkat XML ActiceX object works much better, and doesn't require as much work. Besides, it is very fast, can handle very large files, works well with binary data, compressed data, encrypted data, and much more. In addition, the Xbase++ documentation for the XMLSimpleParser(), XML2Var() and Var2XML() functions is missing from the Xbase++ version 2.00.1392 documentation, and the XMLNode() documentation in general, is relatively sparse, with very few examples. But in principle, the XMLNode() class is very similar to the Chilkat XML class, but simpler and with more limitations. The principle is this: 1) Open the XML file: LOCAL oXML := XMLSimpleParser(cXML_File) or: LOCAL oXML := CreateObject("Chilkat_9_5_0.Xml") oXML:LoadXmlFile(cFileName) After that, you can access all the XML nodes, their values and attributes, their Children, Parents, and Siblings, and edit, add, or remove them, using the corresponding methods, such as: oXML:FindChild(), oXML:GetChild(), oXML:GetChild2(), oXML:FirstChild(), oXML:NextSibling(), oXML:FindChild(), oXML:GetAttributes(), oXML:AddAttribute(), etc. and (with Chilkat) also some properties (or iVars), such as: oXML:Content, oXML:NumAttributes, oXML:NumChildren, oXML:Tag, etc. Chilkat has many more methods (and properties) than the XMLNode class, and the behavior (and syntax) isn't exactly the same, but they are comparable. With XMLNode, you usually create new objects for individual nodes, while with Chilkat you can use the oXML:Xxxx2() methods, which simply move the reference for the (same) oXML object to a different node, saving time and memory, especially with larger and more complex XML files. If you need some additional help, let me know. Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [L]: https://www.LinkedIn.com/in/AndreasGehrsPahl [F]: https://www.FaceBook.com/AbsoluteSoftwareLLC | |
Regan Cawkwell | Re: XML Functions on Fri, 30 Apr 2021 10:18:14 +0100 Hi Andreas Kind of off-topic although directly related... I cannot see in the current documentation where XbpSimpleParser is actually described? I can only see mentions of it in various other XML related functions... We use Chilkat for most XML operations but it's possible that this function could come in handy to read simple XML documents. Regan Rba On 30/04/2021 02:08, Andreas Gehrs-Pahl wrote: > Scott, > >> I need to read some incoming XML files and I'm trying to understand the >> process you need to go through to read and process it using the xbase XML >> functions. > > You can use the Xbase++ ASXML functions or directly XmlSimpleParser(), which > creates an object of the XMLNode class, but in my experience, using the > (free) Chilkat XML ActiceX object works much better, and doesn't require as > much work. Besides, it is very fast, can handle very large files, works well > with binary data, compressed data, encrypted data, and much more. > > In addition, the Xbase++ documentation for the XMLSimpleParser(), XML2Var() > and Var2XML() functions is missing from the Xbase++ version 2.00.1392 > documentation, and the XMLNode() documentation in general, is relatively > sparse, with very few examples. > > But in principle, the XMLNode() class is very similar to the Chilkat XML > class, but simpler and with more limitations. The principle is this: > > 1) Open the XML file: > > LOCAL oXML := XMLSimpleParser(cXML_File) > > or: > > LOCAL oXML := CreateObject("Chilkat_9_5_0.Xml") > oXML:LoadXmlFile(cFileName) > > After that, you can access all the XML nodes, their values and attributes, > their Children, Parents, and Siblings, and edit, add, or remove them, using > the corresponding methods, such as: oXML:FindChild(), oXML:GetChild(), > oXML:GetChild2(), oXML:FirstChild(), oXML:NextSibling(), oXML:FindChild(), > oXML:GetAttributes(), oXML:AddAttribute(), etc. and (with Chilkat) > also some properties (or iVars), such as: oXML:Content, oXML:NumAttributes, > oXML:NumChildren, oXML:Tag, etc. > > Chilkat has many more methods (and properties) than the XMLNode class, and > the behavior (and syntax) isn't exactly the same, but they are comparable. > With XMLNode, you usually create new objects for individual nodes, while > with Chilkat you can use the oXML:Xxxx2() methods, which simply move the > reference for the (same) oXML object to a different node, saving time and > memory, especially with larger and more complex XML files. > > If you need some additional help, let me know. > > Andreas > | |
Scott Krise | Re: XML Functions on Wed, 05 May 2021 12:07:17 -0400 Thanks Andreas. Ill give this a try and be back in touch if I have more questions. "Andreas Gehrs-Pahl" wrote in message news:qyr0jpt04zn4.1vqksdq8xc3oo$.dlg@40tude.net... Scott, >I need to read some incoming XML files and I'm trying to understand the >process you need to go through to read and process it using the xbase XML >functions. You can use the Xbase++ ASXML functions or directly XmlSimpleParser(), which creates an object of the XMLNode class, but in my experience, using the (free) Chilkat XML ActiceX object works much better, and doesn't require as much work. Besides, it is very fast, can handle very large files, works well with binary data, compressed data, encrypted data, and much more. In addition, the Xbase++ documentation for the XMLSimpleParser(), XML2Var() and Var2XML() functions is missing from the Xbase++ version 2.00.1392 documentation, and the XMLNode() documentation in general, is relatively sparse, with very few examples. But in principle, the XMLNode() class is very similar to the Chilkat XML class, but simpler and with more limitations. The principle is this: 1) Open the XML file: LOCAL oXML := XMLSimpleParser(cXML_File) or: LOCAL oXML := CreateObject("Chilkat_9_5_0.Xml") oXML:LoadXmlFile(cFileName) After that, you can access all the XML nodes, their values and attributes, their Children, Parents, and Siblings, and edit, add, or remove them, using the corresponding methods, such as: oXML:FindChild(), oXML:GetChild(), oXML:GetChild2(), oXML:FirstChild(), oXML:NextSibling(), oXML:FindChild(), oXML:GetAttributes(), oXML:AddAttribute(), etc. and (with Chilkat) also some properties (or iVars), such as: oXML:Content, oXML:NumAttributes, oXML:NumChildren, oXML:Tag, etc. Chilkat has many more methods (and properties) than the XMLNode class, and the behavior (and syntax) isn't exactly the same, but they are comparable. With XMLNode, you usually create new objects for individual nodes, while with Chilkat you can use the oXML:Xxxx2() methods, which simply move the reference for the (same) oXML object to a different node, saving time and memory, especially with larger and more complex XML files. If you need some additional help, let me know. Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [L]: https://www.LinkedIn.com/in/AndreasGehrsPahl [F]: https://www.FaceBook.com/AbsoluteSoftwareLLC |