Cordova   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了获取cordova的config.xml的XPath大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

使用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
使用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="dev@cordova.apache.org" 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"));

大佬总结

以上是大佬教程为你收集整理的获取cordova的config.xml的XPath全部内容,希望文章能够帮你解决获取cordova的config.xml的XPath所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。