xml


How comment lines in XML file using Batch file? [duplicate]


This question already has an answer here:
How can you find and replace text in a file using the Windows command-line environment?
24 answers
I have a file context.xml which contains following..
<import resource="beans.xml"/>
I need to comment this line as follows using batch file.. Please help.. Thanks in advance..
<!--import resource="beans.xml"/-->
I tried this.. But its not working..
#echo off
setlocal enableextensions enabledelayedexpansion
set "search= <import resource="beans.xml"/> "
set "replace= <!--import resource="beans.xml"/--> "
set "textFile=context.xml"
for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
>>"%textFile%" echo(!line!
endlocal
)
check the replacer.bat :
call replacer.bat e?content.xml "<import resource=\u0022beans.xml\u0022/>" "<!--import resource=\u0022beans.xml\u0022/-->"
as you have quotes in the strings you want to replace you need e? before the file name which will evaluate the special symbols.

Related Links

Need to remove XML envelope with XSLT
Passing data between XML Views in SAP UI5
how to call all the views from viewholder through different functiions android
Error on importxml function in Google Spreadsheet while scraping Google
macro - can you scrape an xml file and then use it to fill a web form?
read RDF/XML from url in Jena
When does XML receive it's value to display?
Add new tag to the XML using Batch script
space between xml tags
XSL - check if attribute is equal to the selected value
VB.Net TableAdapter XSD file has “randomly” stopped working
Convert XML to CSV with XSLT
Obtain value from XML element using XML parser and assign it to a variable
How to parse xml in powershell
How to hide External Header in Odoo reports using XML
How can I parse XML in PowerShell when each property has a unique name?

Categories

HOME
phantom-dsl
deep-learning
spark-streaming
fuelux
c++11
merge
ggplot2
alexa-skills-kit
flex
sh
sitecore
bitbucket-api
big-o
nuget-package
nfs
title
naivebayes
capistrano3
fileserver
easyphp
user-experience
cgbitmapcontext
object-storage
jboss6.x
windows-server-2003
oculus
gp
uitapgesturerecognizer
google-earth
boost-asio
userdefaults
playstation-portable
openerp-7
nohup
doc
watchface
lpsolve
knime
flask-login
stylecop
procfile
httr
httrack
tinkerpop
jqchart
dt
quicktime
pocketsphinx-android
pure-css
flex-monkey
spring-cloud-feign
ng-grid
vorpal.js
uiactionsheet
cortex-m
jparsec
opl
jdi
extjs-grid
sony-lifelog-api
jsvc
linked-tables
ansi
rrule
umlgraph
at-job
uncaught-typeerror
teaspoon
raygun
trdion2011
draw2d-js
terminate
amslidemenu
openargs
android-usb
windows-phone-8-sdk
nevron
font-awesome-4.0.0
composite-component
pagedown
superscrollorama
mkv
nokia-s40
rmiregistry
subproject
usertype
failing-tests
kqueue
stress
node-redis
expression-blend-4
dataform
build-environment
todos
soappy

Resources

Encrypt Message