我把这行作为uml文档的一部分。如何从JavaScript中的一行XML中获取属性?
<children xmi:type="corstr:heighj" uml:name="private" x="255" y="188" width="221" height="51"/>
- 我需要为X,Y的宽度和高度*
我用这个函数试图值
function getValues(mainBlock, valueLine) {
console.log("searching for data in " + valueLine)
console.log("x? " + getValueFromLine(valueLine, "x=\""));
console.log("y? " + getValueFromLine(valueLine, "y=\""));
console.log("width? " + getValueFromLine(valueLine, "width=\""));
function getValueFromLine(valueLine, searchFor)
{
var position = valueLine.indexOf(searchFor);
return valueLine.substr(position + searchFor.length, (valueLine.indexOf("\"", position + searchFor.length)) - position + searchFor.length);
}
但显然东西是错误的,所以我得到这个在控制台
x? 255" y="1<br>
index1.html:179 y? 188" width<br>
index1.html:180 width? 221" height="51"/