Curiosities during an XML file exploitation











up vote
-3
down vote

favorite












My purpose is an easy string find and replace in an XML File.
But in this file I have several lines with this characters pattern: <!. When my command for /F "tokens=* delims=" %%r in ('myfile.xml) meet this pattern the value of %%r has not the beginning of block:



The second line of my file is:



<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by MTPI (MTPI) -->


and I get the value (//www.xmlspy.com) by MTPI (MTPI) --> in my variable row (%%r)



The second curiosity is about the using variables with the replace syntax:



row=!row:%searchPattern%=%replacePattern%!


where searchPattern = ^<Debug^>1^</Debug^> and replacePattern = ^<Debug/^>!



The using variables doesn't work or my write is wrong I must use the hard values
I would like to use variables



Could you help me for the first anomaly the partial line retrieving?










share|improve this question




















  • 2




    Sorry, but your question is pretty unclear... You should list a section of your file, the desired output and the real output because we can not see your screen from here... About the second "curiosity" (please, don't call this way the things you don't understand) just enclose in quotes the variable and its value: set "row=!row:%searchPattern%=%replacePattern%!" (I assumed that you are using a set command. Why you didn't show it?).
    – Aacini
    Nov 7 at 10:56










  • I have never heard of this MS-DOS replace syntax. What command are you using, and are you actually running this under DOS and not under a commandline in Windows?
    – Bernhard Eriksson
    Nov 7 at 11:22










  • That code has nothing to do with MS-DOS or Windows batch, and your question is very unclear. I have no idea what your problem is here, or what the random link to XMLSpy is supposed to provide, and I don't know what the anomaly is that you're asking for help with here.
    – Ken White
    Nov 7 at 13:38










  • I would highly advise you to use a different scripting language to do changes to an XML file. Powershell, Jscript and Vbscript all have native methods to read and write XML files. You basically have to brute force it with batch files.
    – Squashman
    Nov 7 at 16:23















up vote
-3
down vote

favorite












My purpose is an easy string find and replace in an XML File.
But in this file I have several lines with this characters pattern: <!. When my command for /F "tokens=* delims=" %%r in ('myfile.xml) meet this pattern the value of %%r has not the beginning of block:



The second line of my file is:



<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by MTPI (MTPI) -->


and I get the value (//www.xmlspy.com) by MTPI (MTPI) --> in my variable row (%%r)



The second curiosity is about the using variables with the replace syntax:



row=!row:%searchPattern%=%replacePattern%!


where searchPattern = ^<Debug^>1^</Debug^> and replacePattern = ^<Debug/^>!



The using variables doesn't work or my write is wrong I must use the hard values
I would like to use variables



Could you help me for the first anomaly the partial line retrieving?










share|improve this question




















  • 2




    Sorry, but your question is pretty unclear... You should list a section of your file, the desired output and the real output because we can not see your screen from here... About the second "curiosity" (please, don't call this way the things you don't understand) just enclose in quotes the variable and its value: set "row=!row:%searchPattern%=%replacePattern%!" (I assumed that you are using a set command. Why you didn't show it?).
    – Aacini
    Nov 7 at 10:56










  • I have never heard of this MS-DOS replace syntax. What command are you using, and are you actually running this under DOS and not under a commandline in Windows?
    – Bernhard Eriksson
    Nov 7 at 11:22










  • That code has nothing to do with MS-DOS or Windows batch, and your question is very unclear. I have no idea what your problem is here, or what the random link to XMLSpy is supposed to provide, and I don't know what the anomaly is that you're asking for help with here.
    – Ken White
    Nov 7 at 13:38










  • I would highly advise you to use a different scripting language to do changes to an XML file. Powershell, Jscript and Vbscript all have native methods to read and write XML files. You basically have to brute force it with batch files.
    – Squashman
    Nov 7 at 16:23













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











My purpose is an easy string find and replace in an XML File.
But in this file I have several lines with this characters pattern: <!. When my command for /F "tokens=* delims=" %%r in ('myfile.xml) meet this pattern the value of %%r has not the beginning of block:



The second line of my file is:



<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by MTPI (MTPI) -->


and I get the value (//www.xmlspy.com) by MTPI (MTPI) --> in my variable row (%%r)



The second curiosity is about the using variables with the replace syntax:



row=!row:%searchPattern%=%replacePattern%!


where searchPattern = ^<Debug^>1^</Debug^> and replacePattern = ^<Debug/^>!



The using variables doesn't work or my write is wrong I must use the hard values
I would like to use variables



Could you help me for the first anomaly the partial line retrieving?










share|improve this question















My purpose is an easy string find and replace in an XML File.
But in this file I have several lines with this characters pattern: <!. When my command for /F "tokens=* delims=" %%r in ('myfile.xml) meet this pattern the value of %%r has not the beginning of block:



The second line of my file is:



<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by MTPI (MTPI) -->


and I get the value (//www.xmlspy.com) by MTPI (MTPI) --> in my variable row (%%r)



The second curiosity is about the using variables with the replace syntax:



row=!row:%searchPattern%=%replacePattern%!


where searchPattern = ^<Debug^>1^</Debug^> and replacePattern = ^<Debug/^>!



The using variables doesn't work or my write is wrong I must use the hard values
I would like to use variables



Could you help me for the first anomaly the partial line retrieving?







xml windows batch-file cmd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 16:16









Ross Ridge

27.1k54578




27.1k54578










asked Nov 7 at 10:28









Philippe GODEFROY

102




102








  • 2




    Sorry, but your question is pretty unclear... You should list a section of your file, the desired output and the real output because we can not see your screen from here... About the second "curiosity" (please, don't call this way the things you don't understand) just enclose in quotes the variable and its value: set "row=!row:%searchPattern%=%replacePattern%!" (I assumed that you are using a set command. Why you didn't show it?).
    – Aacini
    Nov 7 at 10:56










  • I have never heard of this MS-DOS replace syntax. What command are you using, and are you actually running this under DOS and not under a commandline in Windows?
    – Bernhard Eriksson
    Nov 7 at 11:22










  • That code has nothing to do with MS-DOS or Windows batch, and your question is very unclear. I have no idea what your problem is here, or what the random link to XMLSpy is supposed to provide, and I don't know what the anomaly is that you're asking for help with here.
    – Ken White
    Nov 7 at 13:38










  • I would highly advise you to use a different scripting language to do changes to an XML file. Powershell, Jscript and Vbscript all have native methods to read and write XML files. You basically have to brute force it with batch files.
    – Squashman
    Nov 7 at 16:23














  • 2




    Sorry, but your question is pretty unclear... You should list a section of your file, the desired output and the real output because we can not see your screen from here... About the second "curiosity" (please, don't call this way the things you don't understand) just enclose in quotes the variable and its value: set "row=!row:%searchPattern%=%replacePattern%!" (I assumed that you are using a set command. Why you didn't show it?).
    – Aacini
    Nov 7 at 10:56










  • I have never heard of this MS-DOS replace syntax. What command are you using, and are you actually running this under DOS and not under a commandline in Windows?
    – Bernhard Eriksson
    Nov 7 at 11:22










  • That code has nothing to do with MS-DOS or Windows batch, and your question is very unclear. I have no idea what your problem is here, or what the random link to XMLSpy is supposed to provide, and I don't know what the anomaly is that you're asking for help with here.
    – Ken White
    Nov 7 at 13:38










  • I would highly advise you to use a different scripting language to do changes to an XML file. Powershell, Jscript and Vbscript all have native methods to read and write XML files. You basically have to brute force it with batch files.
    – Squashman
    Nov 7 at 16:23








2




2




Sorry, but your question is pretty unclear... You should list a section of your file, the desired output and the real output because we can not see your screen from here... About the second "curiosity" (please, don't call this way the things you don't understand) just enclose in quotes the variable and its value: set "row=!row:%searchPattern%=%replacePattern%!" (I assumed that you are using a set command. Why you didn't show it?).
– Aacini
Nov 7 at 10:56




Sorry, but your question is pretty unclear... You should list a section of your file, the desired output and the real output because we can not see your screen from here... About the second "curiosity" (please, don't call this way the things you don't understand) just enclose in quotes the variable and its value: set "row=!row:%searchPattern%=%replacePattern%!" (I assumed that you are using a set command. Why you didn't show it?).
– Aacini
Nov 7 at 10:56












I have never heard of this MS-DOS replace syntax. What command are you using, and are you actually running this under DOS and not under a commandline in Windows?
– Bernhard Eriksson
Nov 7 at 11:22




I have never heard of this MS-DOS replace syntax. What command are you using, and are you actually running this under DOS and not under a commandline in Windows?
– Bernhard Eriksson
Nov 7 at 11:22












That code has nothing to do with MS-DOS or Windows batch, and your question is very unclear. I have no idea what your problem is here, or what the random link to XMLSpy is supposed to provide, and I don't know what the anomaly is that you're asking for help with here.
– Ken White
Nov 7 at 13:38




That code has nothing to do with MS-DOS or Windows batch, and your question is very unclear. I have no idea what your problem is here, or what the random link to XMLSpy is supposed to provide, and I don't know what the anomaly is that you're asking for help with here.
– Ken White
Nov 7 at 13:38












I would highly advise you to use a different scripting language to do changes to an XML file. Powershell, Jscript and Vbscript all have native methods to read and write XML files. You basically have to brute force it with batch files.
– Squashman
Nov 7 at 16:23




I would highly advise you to use a different scripting language to do changes to an XML file. Powershell, Jscript and Vbscript all have native methods to read and write XML files. You basically have to brute force it with batch files.
– Squashman
Nov 7 at 16:23

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53187625%2fcuriosities-during-an-xml-file-exploitation%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53187625%2fcuriosities-during-an-xml-file-exploitation%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()