Jump to content
Sign in to follow this  
coucou

Help: add/modify a value in xml file

Recommended Posts

coucou

Hello,

I'm looking for how modifying a value in the here bellow .xml file

%ProgramFiles%\muvee Technologies\muvee Reveal\hklm2.xml

<AppLanguage valuetype="2" value="fr"

<?xml version="1.0" encoding="utf-8" ?> 
- <My_Computer>
- <HKEY_LOCAL_MACHINE>
  <BID valuetype="2" value="00000026" /> 
- <Default>
  <BitField valuetype="2" value="z7fzfdc002" /> 
- <Desc>
  <a1033 name="1033" valuetype="2" value="Default" /> 
  <a2052 name="2052" valuetype="2" value="预设值" /> 
  <a1028 name="1028" valuetype="2" value="預設" /> 
  <a1030 name="1030" valuetype="2" value="Standard" /> 
  <a1031 name="1031" valuetype="2" value="Vorgabe" /> 
  <a3082 name="3082" valuetype="2" value="Predeterminado" /> 
  <a1035 name="1035" valuetype="2" value="Oletus" /> 
  <a1036 name="1036" valuetype="2" value="Par défaut" /> 
  <a1040 name="1040" valuetype="2" value="Predefinito" /> 
  <a1041 name="1041" valuetype="2" value="デフォルト" /> 
  <a1042 name="1042" valuetype="2" value="기본값" /> 
  <a1043 name="1043" valuetype="2" value="Standaard" /> 
  <a1044 name="1044" valuetype="2" value="Default" /> 
  <a1046 name="1046" valuetype="2" value="Padrão" /> 
  <a2070 name="2070" valuetype="2" value="Pré-definido" /> 
  <a1053 name="1053" valuetype="2" value="Standard" /> 
  <a1049 name="1049" valuetype="2" value="По умолчанию" /> 
  </Desc>
  </Default>
  <FirstTrialKey valuetype="2" value="0020AC-M8N1R0-J4BY5X-WBQ9BQ-19ACVJ" /> 
  <PostMakeAlert valuetype="1" value="1" /> 
  <AppPaths valuetype="2" value="C:\Program Files\muvee Technologies\muvee Reveal\" /> 
  <ProductVersion valuetype="2" value="7.0.40.8982" /> 
  <AppLanguage valuetype="2" value="" /> 
  <TemplateDir valuetype="2" value="C:\Documents and Settings\All Users\Application Data\muvee Technologies\071203\0000\0026" /> 
  <AppSamplesPath valuetype="2" value="C:\Program Files\muvee Technologies\muvee Reveal\Samples" /> 
  <PrivateBuild valuetype="2" value="1068" /> 
  <BuildId valuetype="2" value="2056" /> 
  <PartnerID valuetype="2" value="" /> 
  <DefaultStyle valuetype="2" value="S00516_Plain" /> 
  </HKEY_LOCAL_MACHINE>
  </My_Computer>

TNX for any help

coucou

Share this post


Link to post
Share on other sites
lordicast

Hello,

I'm looking for how modifying a value in the here bellow .xml file

%ProgramFiles%\muvee Technologies\muvee Reveal\hklm2.xml

<AppLanguage valuetype="2" value="fr"

What "Value" thats pretty vague...


[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites
coucou

Sorry, i thought my question is clear ^_^

In fact, if you look closely the file content here above, you'll see this line

<AppLanguage valuetype="2" value="" />
I want adding fr in that line, as
<AppLanguage valuetype="2" value="fr" />

I'll appreciate any help

coucou

Share this post


Link to post
Share on other sites
exodius

Wouldn't this do it?

$varcontainingyourxmltext = FileRead ("C:\Program Files\muvee Technologies\muvee Reveal\hklm2.xml")

StringReplace ($varcontainingyourxmltext, <AppLanguage valuetype="2" value="" />, <AppLanguage valuetype="2" value="fr" />)

Share this post


Link to post
Share on other sites
coucou

TNX exodius for yr help,

they were quotation missed. Anyway, the .xml file stay UNmodified ^_^;)

$varcontainingyourxmltext=FileRead(@ProgramFilesDir  & "\muvee Technologies\muvee Reveal\hklm2.xml")
StringReplace($varcontainingyourxmltext, '<AppLanguage valuetype="2" value="" />', '<AppLanguage valuetype="2" value="fr" />')

Share this post


Link to post
Share on other sites
water

To rewrite the file you'll have to add

$hFile = FileOpen("C:\Program Files\muvee Technologies\muvee Reveal\hklm2.xml",2)
FileWrite($hFile,$varcontainingyourxmltext)
FileClose($hFile)
This will replace your xml file with the new content. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
PsaltyDS

Hello,

I'm looking for how modifying a value in the here bellow .xml file

%ProgramFiles%\muvee Technologies\muvee Reveal\hklm2.xml

<AppLanguage valuetype="2" value="fr"

<?xml version="1.0" encoding="utf-8" ?> 
- <My_Computer>
- <HKEY_LOCAL_MACHINE>
  <BID valuetype="2" value="00000026" /> 
- <Default>
  <BitField valuetype="2" value="z7fzfdc002" /> 
- <Desc>
  <a1033 name="1033" valuetype="2" value="Default" /> 
  <a2052 name="2052" valuetype="2" value="预设值" /> 
  <a1028 name="1028" valuetype="2" value="預設" /> 
  <a1030 name="1030" valuetype="2" value="Standard" /> 
  <a1031 name="1031" valuetype="2" value="Vorgabe" /> 
  <a3082 name="3082" valuetype="2" value="Predeterminado" /> 
  <a1035 name="1035" valuetype="2" value="Oletus" /> 
  <a1036 name="1036" valuetype="2" value="Par défaut" /> 
  <a1040 name="1040" valuetype="2" value="Predefinito" /> 
  <a1041 name="1041" valuetype="2" value="デフォルト" /> 
  <a1042 name="1042" valuetype="2" value="기본값" /> 
  <a1043 name="1043" valuetype="2" value="Standaard" /> 
  <a1044 name="1044" valuetype="2" value="Default" /> 
  <a1046 name="1046" valuetype="2" value="Padrão" /> 
  <a2070 name="2070" valuetype="2" value="Pré-definido" /> 
  <a1053 name="1053" valuetype="2" value="Standard" /> 
  <a1049 name="1049" valuetype="2" value="По умолчанию" /> 
  </Desc>
  </Default>
  <FirstTrialKey valuetype="2" value="0020AC-M8N1R0-J4BY5X-WBQ9BQ-19ACVJ" /> 
  <PostMakeAlert valuetype="1" value="1" /> 
  <AppPaths valuetype="2" value="C:\Program Files\muvee Technologies\muvee Reveal\" /> 
  <ProductVersion valuetype="2" value="7.0.40.8982" /> 
  <AppLanguage valuetype="2" value="" /> 
  <TemplateDir valuetype="2" value="C:\Documents and Settings\All Users\Application Data\muvee Technologies\071203\0000\0026" /> 
  <AppSamplesPath valuetype="2" value="C:\Program Files\muvee Technologies\muvee Reveal\Samples" /> 
  <PrivateBuild valuetype="2" value="1068" /> 
  <BuildId valuetype="2" value="2056" /> 
  <PartnerID valuetype="2" value="" /> 
  <DefaultStyle valuetype="2" value="S00516_Plain" /> 
  </HKEY_LOCAL_MACHINE>
  </My_Computer>

TNX for any help

coucou

The XML file can be handled with eltorro's XML DOM UDF. This demo worked:
#include <_XMLDOMWrapper.au3>

$sXML = @ScriptDir & "\Test1.xml"
$sPath = "/My_Computer/HKEY_LOCAL_MACHINE/AppLanguage"
$sAttrib = "Value"
$sValue = "fr"

$oXML = _XMLFileOpen($sXML)
_XMLSetAttrib($sPath, $sAttrib, $sValue)
$oXML = 0

Using this cleaned up xml file for Test1.xml:

<?xml version="1.0" encoding="utf-8"?>
<My_Computer>
    <HKEY_LOCAL_MACHINE>
        <BID valuetype="2" value="00000026"/>
        <Default>
            <BitField valuetype="2" value="z7fzfdc002"/>
            <Desc>
                <a1033 name="1033" valuetype="2" value="Default"/>
                <a2052 name="2052" valuetype="2" value="???"/>
                <a1028 name="1028" valuetype="2" value="??"/>
                <a1030 name="1030" valuetype="2" value="Standard"/>
                <a1031 name="1031" valuetype="2" value="Vorgabe"/>
                <a3082 name="3082" valuetype="2" value="Predeterminado"/>
                <a1035 name="1035" valuetype="2" value="Oletus"/>
                <a1036 name="1036" valuetype="2" value="Par defaut"/>
                <a1040 name="1040" valuetype="2" value="Predefinito"/>
                <a1041 name="1041" valuetype="2" value="?????"/>
                <a1042 name="1042" valuetype="2" value="???"/>
                <a1043 name="1043" valuetype="2" value="Standaard"/>
                <a1044 name="1044" valuetype="2" value="Default"/>
                <a1046 name="1046" valuetype="2" value="Padrao"/>
                <a2070 name="2070" valuetype="2" value="Pre-definido"/>
                <a1053 name="1053" valuetype="2" value="Standard"/>
                <a1049 name="1049" valuetype="2" value="?? ?????????"/>
            </Desc>
        </Default>
        <FirstTrialKey valuetype="2" value="0020AC-M8N1R0-J4BY5X-WBQ9BQ-19ACVJ"/>
        <PostMakeAlert valuetype="1" value="1"/>
        <AppPaths valuetype="2" value="C:\Program Files\muvee Technologies\muvee Reveal\"/>
        <ProductVersion valuetype="2" value="7.0.40.8982"/>
        <AppLanguage valuetype="2" value="" Value="fr"/>
        <TemplateDir valuetype="2" value="C:\Documents and Settings\All Users\Application Data\muvee Technologies\071203\0000\0026"/>
        <AppSamplesPath valuetype="2" value="C:\Program Files\muvee Technologies\muvee Reveal\Samples"/>
        <PrivateBuild valuetype="2" value="1068"/>
        <BuildId valuetype="2" value="2056"/>
        <PartnerID valuetype="2" value=""/>
        <DefaultStyle valuetype="2" value="S00516_Plain"/>
    </HKEY_LOCAL_MACHINE>
</My_Computer>

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
coucou

TNX PsaltyDS,

I just downloaded eltorro's XML DOM UDF latest version, put it in same directory as yr script. When I launch it, i get the following error message

Line 142 (file _XMLDomWrapper.au3)

Func _XMLFileOpen($strXMLFile, $strNameSpc = "", $iVer = -1, $bValOnParse = True)

Error "If" statement has not matching "EndIf" statement

Anywat i thing that is too much script for a small modification

Regards

coucou

Share this post


Link to post
Share on other sites
bluebearr

This should do it:

$sFile = "C:\Program Files\muvee Technologies\muvee Reveal\hklm2.xml"
$varcontainingyourxmltext=FileRead($sFile)
$varcontainingyourxmltext = StringReplace($varcontainingyourxmltext, '<AppLanguage valuetype="2" value="" />', _
  '<AppLanguage valuetype="2" value="fr" />')
$hFile = FileOpen($sFile,2)
FileWrite($hFile,$varcontainingyourxmltext)
FileClose($hFile)

BlueBearr


BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites
coucou

Wooowww

Many TNX BlueBearr

works like a charm ^_^

coucou

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×