使用cordovas confix.xml,默认文件是这个.
<?xml version='1.0' encoding='utf-8' ?> <widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>HelloCordova</name> <description> A sample Apache Cordova application that responds to the deviceready event. </description> <author email="[email protected]" href="http://cordova.io"> Apache Cordova Team </author> <content src="index.html" /> <plugin name="cordova-plugin-whitelist" version="1" /> <access origin="*" /> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="tel:*" /> <allow-intent href="sms:*" /> <allow-intent href="mailto:*" /> <allow-intent href="geo:*" /> <platform name="android"> <allow-intent href="market:*" /> </platform> <platform name="ios"> <allow-intent href="itms:*" /> <allow-intent href="itms-apps:*" /> </platform> </widget>
使用gulp-xml-editor我正在尝试创建一个插件来编辑name的值,但无论我如何尝试,我都无法获得正确的xpath元素.
我试过的选项:
> .//* [name]
> .//*/widgets:name
> //名字
没有成功.知道它是什么?
解决方法
元素< name>在默认名称空间xmlns =“http://www.w3.org/ns/widgets”中.通常在xpath中,要选择命名空间中的元素,您需要注册指向命名空间uri的前缀,并在xpath中使用该前缀.
我不知道gulp-xml-editor,但是在GitHub页面you linked中似乎有一个非常接近的例子,特别是评论“使用命名空间使用用户特定对象编辑XML文档”:
/* edit XML document by using user specific object using a namespace */ gulp.src("./manifest.xml") .pipe(xeditor([ {path: '//xmlns:name',text: 'new names'},],'http://www.w3.org/ns/widgets')) .pipe(gulp.dest("./dest"));
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。