javascript - 请问这个js库的方法是什么意思?

查看:113
本文介绍了javascript - 请问这个js库的方法是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

这是一个Photoshop 的xml.js 库的一个对象方法,我不会英语,用 有道翻译 的又看不懂..
请有空的人能教教我怎么用吗?
我只能用点赞汇报大家了,谢谢...

replace()
xmlObj.replace (name, value);
name
An element or attribute name, with or without the 0-based position index of a
specific element, or the wildcard string *.
? If no position index is supplied, replaces the value of all matching elements.
? If the wildcard is supplied, replaces the value of all contained elements. When an
element contain subelements, those are removed, and only the replacement
value
remains.
value An XML object or any value that can be converted to a String with toString().
Replaces one or more property values in this node.
If the named element does not exist, appends the given value as a text element.
Returns this XML object.
setChildren()
xmlObj.

解决方案

这是个替换函数。
name是你需要替换的元素或属性名,可以指定下标index,或者通选符‘*’。
如果不提供下标,所有符合name的元素都会被替换。
如果是‘*’,替换所有包含的元素,如果元素有子元素,则直接移除。
value是个XML对象或者任何能被toString()函数转换为字符串的值。
特殊情况:如果name不存在,则直接将value作为一个文本元素append进去。
返回的是XML对象。

这篇关于javascript - 请问这个js库的方法是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆