Function ReadXML
Lparameters pcXMLFile
Local oXML, oRootNode, cParentName, cValue, cName, nType, nNumNodes, ;
	cRootTagName, oNodeList, oNode, bHasChild, cTagName, ;
	oChildNodeList, nChildLen, nPass, oChildNode, oAttributeList, ;
	cTextData, nTextDataLen, cAttrName, cAttrValue, nNumAttr

* Start out by creating the actual xml parser object
oXML = Createobject('MSXML2.DomDocument')

* Wait for the document to be parsed and loaded
oXML.Async = .F.

* Load the document into the object, if this was a stream instead
* of a file name, we would use loadXML(cCharStream)
oXML.Load(pcXMLFile)

* Get the root element
oRootNode = oXML.documentElement

* What is the root tag name?
cRootTagName = oRootNode.tagName

* Get all the nodes in the document with the special '*'
* parameter, we could just pass in a tag name to get the
* node list for that specific tag
oNodeList = oRootNode.getElementsByTagName("*")

* How many nodes did we retrieve
nNumNodes = oNodeList.Length

* Go through all the nodes in the NodeList.
* Note that Attribute and Character/Text Data is NOT
* counted as part of this list, you must get that data
* separately, this list only contains tag elements
* Note that this uses C like array positioning by
* starting at zero

For nPos = 0 To (nNumNodes-1) Step 1

	* Get the next node in the list
	oNode = oNodeList.Item(nPos)

	* What is the value of this node, if it is an element
	* then this value is the tag name
	cParentName = oNode.nodeName

    *-----------------------------------------------
    * TRABAJANDO CON EL CURSOR DE LAS TASAS
	lcNodoEvaluar = Upper(Alltrim(cParentName))
	If lcNodoEvaluar=="FECHA"
		Select crsTASA
		Append Blank
	Endif
    *-----------------------------------------------
	* Does this node have any children?
	bHasChild = oNode.hasChildNodes()

	* What is the node type, element or text?
	nType = oNode.nodeType

	If nType = 1
		* This is an element/tag so it may have
		* attributes.  We can get those attributes
		* by name or in a list.
		* Since this example function traverses thru
		* the xml tree, it would not be very efficient
		* to query every single node for a particular
		* attribute, this is just to show how it could
		* be done.

		* if the attribute does not exist, returns .NULL.
		* otherwise we get the attribute value
		cAttrValue = oNode.getAttribute("my_attribute")

		* We could also get a NamedNodeMap accessing
		* the attributes property
		oAttributeList = oNode.Attributes

		* how many attributes do we have
		nNumAttr = oAttributeList.Length

		* Get the attribute using the list
		cAttrValue = oAttributeList.getNamedItem("my_attribute")
	Endif

	If bHasChild
		* Ok, we know we have children but what type are they?
		* Just test the first one to see if it is something
		* other than an element and if so, get it
		If oNode.firstChild.nodeType != 1
			* We know we have something other than an element, get
			* the tag name of the element we are parsing
			cTagName = oNode.tagName

			* Get the node list and determine how man child
			* nodes this element has
			oChildNodeList = oNode.childNodes
			nChildLen = oChildNodeList.Length

			* Go through all child nodes and grab the non-element
			* data to do with what you like
			For nPass = 0 To (nChildLen-1) Step 1

				oChildNode = oChildNodeList.Item(nPass)
				cValue = oChildNode.nodeValue
				cName = oChildNode.nodeName
				nType = oChildNode.nodeType
				bHasChild = oChildNode.hasChildNodes()
				
				*-----------------------------------------------
			    * TRABAJANDO CON EL CURSOR DE LAS TASAS
				If Alltrim(Upper(cTagName))="FECHA"
					Set Date To YMD
					Select crsTASA
					Go Bottom
					Replace crsTASA.fecha With Ctod(cValue)
				Endif
				If Alltrim(Upper(cTagName))="VALOR"
					Select crsTASA
					Go Bottom
					Replace crsTASA.valor With Val(cValue)
				Endif
				*-------------------------------------
				* For now just look for text types, other
				* types can be added later if needed
				Do Case
				Case nType = 3
					* Text node
					cTextData = oChildNode.Data
					nTextDataLen = oChildNode.Length
				Case nType = 4
					* CData Section node
					cTextData = oChildNode.Data
					nTextDataLen = oChildNode.Length
				Otherwise
					* Some other node we don't care about
					* right now
				Endcase
			Endfor

		Endif
	Endif
Endfor

Return 0
Endfunc