Jump to content

BigBook

Members
  • Posts

    3
  • Joined

  • Last visited

BigBook's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thx a lot, mLipok. I think i use the wrapper the wrong way. Would be glad if you give me a kick in the right direction.
  2. Probably not the right place for my question?
  3. Hi, i'm new to autoit and new to xml. I'd like to create a XML file with the wrapper .... but still have some problems. Not sure if this is a wrapper problem (Probably not. :-)) With this code snippet: ;create xml object Local $oXMLDoc = _XML_CreateDOMDocument() if @error Then ConsoleWrite("Error _XML_CreateDOMDocument. Error: " & @error & " Extended: " & @extended & @LF) EndIf local $sXML_Content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> ' & @CRLF $sXML_Content &= '<FILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' & @CRLF $sXML_Content &= '</FILE>' _XML_LoadXml($oXMLDoc, $sXML_Content) $aDeptCodeTemp[0][0] = "DEPT_CODE" $aDeptCodeTemp[0][1] = "1" $sXMLString = "FILE" ; first child 'record' _XML_CreateChildWAttr($oXMLDoc, $sXMLString, "RECORD", $aDeptCodeTemp) ; second child "Field1" $sXMLString &= "/" & "Field1" _XML_InsertChildNode($oXMLDoc, $sXMLString, "FIELD1") $sXMLValue = _XML_Tidy($oXMLDoc, 'UTF-8') _XML_LoadXml($oXMLDoc, $sXMLValue) _XML_SaveToFile($oXMLDoc, $aFilePath) I get this file: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <FILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RECORD DEPT_CODE="01"> <FIELD1/> </RECORD> </FILE> I need more 'RECORD' nodes with the same data in it. ;create xml object Local $oXMLDoc = _XML_CreateDOMDocument() if @error Then ConsoleWrite("Error _XML_CreateDOMDocument. Error: " & @error & " Extended: " & @extended & @LF) EndIf local $sXML_Content = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> ' & @CRLF $sXML_Content &= '<FILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' & @CRLF $sXML_Content &= '</FILE>' _XML_LoadXml($oXMLDoc, $sXML_Content) $aDeptCodeTemp[0][0] = "DEPT_CODE" $aDeptCodeTemp[0][1] = "1" $sXMLString = "FILE" ; first child 'record' _XML_CreateChildWAttr($oXMLDoc, $sXMLString, "RECORD", $aDeptCodeTemp) ; second child "Field1" $sXMLString &= "/" & "Field1" _XML_InsertChildNode($oXMLDoc, $sXMLString, "FIELD1") $aDeptCodeTemp[0][0] = "DEPT_CODE" $aDeptCodeTemp[0][1] = "2" $sXMLString = "FILE" ; first child 'record' _XML_CreateChildWAttr($oXMLDoc, $sXMLString, "RECORD", $aDeptCodeTemp) ; second child "Field1" $sXMLString &= "/" & "Field1" _XML_InsertChildNode($oXMLDoc, $sXMLString, "FIELD1") $sXMLValue = _XML_Tidy($oXMLDoc, 'UTF-8') _XML_LoadXml($oXMLDoc, $sXMLValue) _XML_SaveToFile($oXMLDoc, $aFilePath) Give me this file: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <FILE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <RECORD DEPT_CODE="01"> <FIELD1/> <FIELD1/> </RECORD> <RECORD DEPT_CODE="02"> <FIELD1/> </RECORD> </FILE> In the first "RECORD" node is one "FIELD1" child-node too much. Pretty clear why ... but no clue how to fix it. Where is my mistake? How can i insert a child-node only in the last "RECORD" node? Thx for some hints ...
×
×
  • Create New...