ManelRodero Posted July 29, 2009 Posted July 29, 2009 (edited) Hello, I'm trying to use _XMLDomWrapper for modifying a XML configuration file for Windows Media Encoder without success. The XML is the following one: expandcollapse popup<?xml version="1.0"?> <WMEncoder major_version="9" minor_version="0" Name="WMEncoder7001" SynchroniesOperation="0" > <Description Author="STR_AUTHOR" Title="STR_TITLE" Copyright="STR_COPYRIGHT" Description="STR_DESCRIPTION" /> <SourceGroups > <SourceGroup Name="ExtronScaler" > <Source Type="WMENC_VIDEO" Scheme="screencap" PixelAspectRatioX="1" PixelAspectRatioY="1" > <UserData > <WMENC_STRING Name="WindowTitle" /> <WMENC_LONG Name="CaptureWindow" Value="0" /> <WMENC_LONG Name="Left" Value="0" /> <WMENC_LONG Name="Top" Value="0" /> <WMENC_LONG Name="Right" Value="1680" /> <WMENC_LONG Name="Bottom" Value="1050" /> <WMENC_DOUBLE Name="FrameInterval" Value="0.0400" /> <WMENC_BOOL Name="FlashRect" Value="no" /> <WMENC_BOOL Name="Screen" Value="yes" /> </UserData> </Source> <Source Type="WMENC_AUDIO" Scheme="device" InputSource="Default_Audio_Device" > <UserData > <WMENC_BOOL Name="UseRecordQueue" Value="no" /> <WMENC_STRING Name="RecordTempPath" Value="C:\DOCUME~1\ADMINI~1\CONFIG~1\Temp\" /> <WMENC_STRING Name="MinimumDiskSpace" Value="10485760" /> <WMENC_BOOL Name="SaveToDiskOnlyDuringCapture" Value="no" /> </UserData> </Source> <EncoderProfile id="Streaming FIB Encoding" /> <UserData > <WMENC_LONG Name="Video0\CropMethod" Value="0" /> <WMENC_LONG Name="Video0\CropCustomT" Value="0" /> <WMENC_LONG Name="Video0\CropCustomL" Value="0" /> <WMENC_LONG Name="Video0\CropCustomR" Value="0" /> <WMENC_LONG Name="Video0\CropCustomB" Value="0" /> </UserData> </SourceGroup> </SourceGroups> <File LocalFileName="D:\VIDEOS\AAAAMMDD_HHMM_STR_TITLE_FILE.wmv" /> <Broadcast Http="8080" PublishServer="wmserver" PublishingPoint="sala-actes" PublishPort="80" /> <WMEncoder_Profile id="Streaming FIB Encoding" > <![CDATA[ <profile version="589824" storageformat="1" name="Streaming FIB Encoding" description=" "> <streamconfig majortype="{73647561-0000-0010-8000-00AA00389B71}" streamnumber="1" streamname="Audio Stream" inputname="Audio40a" bitrate="128016" bufferwindow="5000" reliabletransport="0" decodercomplexity="" rfc1766langid="es" > <wmmediatype subtype="{00000161-0000-0010-8000-00AA00389B71}" bfixedsizesamples="1" btemporalcompression="0" lsamplesize="2731"> <waveformatex wFormatTag="353" nChannels="2" nSamplesPerSec="48000" nAvgBytesPerSec="16002" nBlockAlign="2731" wBitsPerSample="16" codecdata="008800000F0000000000"/> </wmmediatype> </streamconfig> <streamconfig majortype="{73646976-0000-0010-8000-00AA00389B71}" streamnumber="2" streamname="Video Stream" inputname="Video40a" bitrate="682000" bufferwindow="5000" reliabletransport="0" decodercomplexity="AU" rfc1766langid="es" > <videomediaprops maxkeyframespacing="40000000" quality="90"/> <wmmediatype subtype="{33564D57-0000-0010-8000-00AA00389B71}" bfixedsizesamples="0" btemporalcompression="1" lsamplesize="0"> <videoinfoheader dwbitrate="682000" dwbiterrorrate="0" avgtimeperframe="400000"> <rcsource left="0" top="0" right="0" bottom="0"/> <rctarget left="0" top="0" right="0" bottom="0"/> <bitmapinfoheader biwidth="0" biheight="0" biplanes="1" bibitcount="24" bicompression="WMV3" bisizeimage="0" bixpelspermeter="0" biypelspermeter="0" biclrused="0" biclrimportant="0"/> </videoinfoheader> </wmmediatype> </streamconfig> </profile> ]]> </WMEncoder_Profile> <UserData > <WMENC_LONG Name="Encoding\Dest" Value="2" /> <WMENC_LONG Name="Encoding\Bitrate0\Video0\CustomW" Value="0" /> <WMENC_LONG Name="Encoding\Bitrate0\Video0\CustomH" Value="0" /> <WMENC_LONG Name="Encoding\LocalComplexity" Value="-1" /> <WMENC_LONG Name="Encoding\BroadcastComplexity" Value="-1" /> <WMENC_STRING Name="Encoding\Audio0" /> <WMENC_STRING Name="Encoding\Video0" /> <WMENC_STRING Name="Encoding\Script0" /> </UserData> </WMEncoder> How can I do the following: 1) Change the value of 'Author' attribute in 'Description' section (this section is always in the XML file): <Description Author="STR_AUTHOR" Title="STR_TITLE" Copyright="STR_COPYRIGHT" Description="STR_DESCRIPTION" /> 2) Add some nodes like these ones (the section 'File' and the Section 'Broadcast' aren't in the file initially but must be added by code and independently): <File LocalFileName="D:\VIDEOS\AAAAMMDD_HHMM_STR_TITLE_FILE.wmv" /> <Broadcast Http="8080" PublishServer="wmserver" PublishingPoint="sala-actes" PublishPort="80" /> I've tried the following code: Dim $attribs = _ArrayCreate("Http","PublishServer","PublishingPoint","PublishPort") Dim $values = _ArrayCreate("8080","wmserver","sala-actes","80") _XMLCreateRootNodeWAttr ( 'Broadcast', $attribs, $values) ConsoleWrite("After Create RootNode" & @LF) and I get the node inserted in the XML but the program exits with an error and the ConsoleWrite code isn't executed: -1 D:\AutoIt\_XMLDomWrapper.au3 (2011) : ==> Variable used without being declared.: $objFormat = $objDoc.createTextNode(@CR) ^ ERROR Any idea about what's the problem with the CreateRootNodeWAttr function? Thank you! PS: The code inside _XMLDomWrapper with the error is this one: Func _AddFormat($objDoc, $objParent = "") If $fADDFORMATTING = True Then If Not IsObj($objDoc) Then _XMLError("No object passed to function _XMLAddFormat") Return SetError(1, 30, -1) EndIf $objFormat = $objDoc.createTextNode(@CR) If IsObj($objParent) Then $objParent.appendChild($objFormat) Else $objDoc.documentElement.appendChild($objFormat) EndIf _XMLSaveDoc($strFile) EndIf Return 1 EndFunc ;==>_AddFormat Edited July 29, 2009 by ManelRodero
Authenticity Posted July 29, 2009 Posted July 29, 2009 #include <_XMLDomWrapper.au3> #include <Array.au3> Global Const $sFile = @ScriptDir & '\file.xml' If _XMLFileOpen($sFile) = 1 Then _XMLSetAttrib('//Description', 'Author', 'Value') Local $aAttr = StringSplit('Http|PublishServer|PublishingPoint|PublishPort', '|') Local $aValues = StringSplit('8080|wmserver|sala-actes|80', '|') Local $oNodeBefore = $objDoc.createNode($NODE_ELEMENT, 'File', '') Local $oNodeAfter = $objDoc.selectSingleNode('WMEncoder/WMEncoder_Profile') $oNodeAfter.parentNode.insertBefore($oNodeBefore, $oNodeAfter) $oNodeBefore.setAttribute('LocalFileName', 'D:\VIDEOS\AAAAMMDD_STR_TITLE_FILE.wmv') $oNodeBefore = $objDoc.createNode($NODE_ELEMENT, 'Broadcast', '') $oNodeAfter.parentNode.insertBefore($oNodeBefore, $oNodeAfter) For $i = 1 To $aAttr[0] $oNodeBefore.setAttribute($aAttr[$i], $aValues[$i]) Next $objDoc.save($sFile) EndIf
ManelRodero Posted July 30, 2009 Author Posted July 30, 2009 x Authenticy: Hello, Thank you very much for your code. It works wonderfully! But, I don't understand why we can't use XML DOM Wrapper functions defined in the library and we need to go through coding at "low level" (using $objDoc, etc.) for inserting nodes. Is a problem of the library? Is a better approach to solve this kind of problems? Only curiosity ... Thanks again!
HariKara Posted April 16, 2018 Posted April 16, 2018 On 7/29/2009 at 1:56 PM, ManelRodero said: <WMENC_LONG Name="Encoding\LocalComplexity" Value="-1" /> How would you edit only the above Tag in your script. Say you wanted that to read as <WMENC_LONG Name="ENCODER">version5</WMENC_LONG>
Moderators Melba23 Posted April 16, 2018 Moderators Posted April 16, 2018 HariKara, As the post above yours dates from 9 years ago and the poster has not been here since then, do you really expect an answer? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Subz Posted April 16, 2018 Posted April 16, 2018 Local $sFileName = @ScriptDir & "\Filename.xml" Local $oErrorHandler = ObjEvent("AutoIt.Error", "_XmlErrFunc") Local $oXMLDoc = ObjCreate("MSXML2.DOMDocument") $oXMLDoc.validateOnParse = False $oXMLDoc.load($sFileName) Local $oNode = $oXMLDoc.selectSingleNode("/WMENC_LONG") $oNode.setAttribute("Name", "ENCODER") $oNode.removeAttribute("Value") $oNode.Text = "version5" $oXMLDoc.save($sFileName) Func _XmlErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now