为此,要遍历结果数组,每次获取一个单独元素的引用并检索它的属性。
To do that, you go through the results array, each time getting a reference to the individual element and retrieving its attributes.
清单8所示的代码中,可以像访问数组元素一样访问元素的属性。
In the code shown in Listing 8, you access attributes of an element just as you would elements of an array.
我们可以使用数组语法访问多值属性的个别元素,例如第一个地址。
We can access individual elements of many-valued properties, such as the first address, using array syntax.
在这个例子中,使用了两个DHTML技术:forms数组,以及通过基于属性值的名称调用元素(而不是通过元素名或总体结构)。
In this case, you see two DHTML techniques: the forms array, and calling elements by names based on attribute values, rather than by element names or by overall structure.
如果一个元素包含多个相同名称的子元素,这些子元素将转换为一个数组属性。
If an element contains more than one sub-element of the same name, those sub-elements will be turned into an array property.
虽然以数组形式保存属性是一种典型实现,但元素的属性是一个无序集,因此其他解析器实现可以以更有效的方式保存属性。
Although storing attributes in array form is a typical implementation, an element's attributes are an unordered set, so other parser implementations may store attributes in a more efficient way.
为了实现您老板的第一个要求(将子元素转换为属性),需要替换对数组的引用,如清单10所示。
To achieve your boss's first objective, which is to convert elements to attributes, you need to replace references to arrays, as shown in Listing 10.
清单9中就像访问数组成员一样访问元素的属性。
In Listing 9, access attributes of an element just as you would elements of an array.
您可以直接使用.childnodes属性数组来保存一些字符,但这种样式是脆弱的,例如,如果有子元素,而没有的话。
You might use the.childnodes attribute array directly to save a few characters, but this is fragile if, for example, there are children of other than.
数组元素和对象属性是一样的,所以它们是这样被访问的。
Array elements are nothing less than object properties, so they are accessed as such.
清单中还引入了一个新属性:keyAttribute 属性,它告诉XJConf设置输出关联数组的键时使用哪个元素属性。
Notice also a new attribute introduced in this listing: The keyAttribute attribute, which tells XJConf which element attribute to consider when it sets the keys of the output associative array.
注意定义文件中type属性的值:元素映射到一个数组,嵌套的映射为简单字符串值。
Notice the values of the type attribute in this definition file: the element is mapped to an array, while the nested s are mapped to simple string values.
如果该XML元素包含属性,也可以将SimpleXMLElement作为一个PHP关联数组进行访问,数组中的每个键表示xml元素的属性。
If the XML element in question contains attributes, you can also access the SimpleXMLElement as a PHP associative array, where each key in the array represents an attribute on the XML element.
foreach语句,不是设置来自sql结果集的域属性值,而是将字符串TODO:setfrom sqlresult填塞到字段值数组的每个元素。
The foreach statement, instead of setting domain attribute values from a SQL result set, stuffs the string TODO: set from SQL result into each element of the array of field values.
保存CGI参数的数组是由元素中action属性的值决定的。
The array in which the CGI parameters are held depends on the value of the action attribute in the element.
这个项目向你展示了如何创建控件数组,在窗体中载入它们的元素,这样它们就是可视的,并完全显示出来,设置它们的属性,然后卸载它们。
This project shows you how to create control arrays, load their elements on forms so they are visible and display properly, set their properties, and unload them.
如果相应语句为某个表达式赋值,请用一个可写的变量、属性或数组元素替换该表达式。
If the statement assigns a value to an expression, replace the expression with a single writable variable, property, or array element.
只有对对象属性或数组元素的更改才会在函数外可见。
Only changes to properties of objects, or elements of arrays, are visible outside the function.
函数的作用是:计算数组中的元素数目或对象中的属性个数。
The count() function counts the elements of an array, or the properties of an object.
确保属性的一个参数指定了一个具有相同秩(维数)和元素数据类型的数组。
Ensure that one of the property parameters specifies an array with the same rank (number of dimensions) and element data type.
确保属性的一个参数指定了一个具有相同秩(维数)和元素数据类型的数组。
Ensure that one of the property parameters specifies an array with the same rank (number of dimensions) and element data type.
应用推荐