> loNode2 = loNode.selectSingleNode("ProductCode") > ? loNode2.text > messagebox(loNode2.text) > replace ref WITH loNode2.text > > loNode2 = loNode.selectSingleNode("Quantity") > ? loNode2.text > messagebox(loNode2.text) > replace qtt WITH VAL(loNode2.text) > >>
>>LOCAL loXMLDoc, loRoot, loNodes, loNode >> >>* Create a new DOMDocument object >>loXMLDoc = CREATEOBJECT("MSXML2.DOMDocument") >> >>* Load the XML file >>lcXMLFile = GETFILE("XML") >>IF !loXMLDoc.load(lcXMLFile) >> ? "Error loading XML file:" >> ? loXMLDoc.parseError.reason >> RETURN >>ENDIF >> >>CREATE CURSOR crs ( ref C(18), qtt N(10,6)) >>* Get the root element of the XML document >>loRoot = loXMLDoc.documentElement >> >>* Access multiple nodes using selectNodes >>loNodes = loRoot.selectNodes("//SourceDocuments/SalesInvoices/Invoice/Line") >> >> >>* Loop through the nodes using FOR EACH >>FOR EACH loNode IN loNodes >> SELECT crs >> APPEND BLANK >> >> loNode = loNode.selectSingleNode("ProductCode") >> ? loNode.text >> messagebox(loNode.text) >> replace ref WITH loNode.text >> >> loNode = loNode.selectSingleNode("Quantity") >> ? loNode.text >> messagebox(loNode.text) >> replace qtt WITH VAL(loNode.text) >> * Perform additional operations with the node, if needed >> >>ENDFOR >> >>SELECT crs >>BROWSE nowait >>>>
>> loNode = loNode.selectSingleNode("Quantity") >> ? loNode.text >> messagebox(loNode.text) >> replace qtt WITH VAL(loNode.text) >>>>the code work fine, but if have two , like this:
>> loNode = loNode.selectSingleNode("ProductCode") >> ? loNode.text >> messagebox(loNode.text) >> replace ref WITH loNode.text >> >> loNode = loNode.selectSingleNode("Quantity") >> ? loNode.text && ERROR HERE >> messagebox(loNode.text) >> replace qtt WITH VAL(loNode.text) >>>>VFP , return on comment &&ERROR HERE with this message:
loNodes = loRoot.selectNodes("//SourceDocuments/SalesInvoices/Invoice/Line") * loNodes it¨s collection of nodes FOR EACH loNode IN loNodes * now loNode contains reference to Line item in loNodes collection debugout loNode.xml * next line replace reference to another xml object loNode = loNode.selectSingleNode("ProductCode") debugout loNode.xml * next line do "ba da bum", because loNode it's reference to ProductCode loNode = loNode.selectSingleNode("Quantity")MartinaJ