页面code:
<mx:MenuBar id="myMenuBar" labelField="@label" width="100%">
<mx:XMLList>
<menuitem label="MenuItem A">
<menuitem label="SubMenuItem A-1" enabled="false"/>
<menuitem label="SubMenuItem A-2"/>
</menuitem>
</mx:XMLList>
</mx:MenuBar>
我想取到myMenuBar 的属性width的值. 看了API试验了很多次都没有找到怎么做,各位求救啊!
<mx:MenuBar id="myMenuBar" labelField="@label" width="100%">
<mx:XMLList>
<menuitem label="MenuItem A">
<menuitem label="SubMenuItem A-1" enabled="false"/>
<menuitem label="SubMenuItem A-2"/>
</menuitem>
</mx:XMLList>
</mx:MenuBar>
我想取到myMenuBar 的属性width的值. 看了API试验了很多次都没有找到怎么做,各位求救啊!
<books>
<book email="zhoujunhui">
<name>rjzjh</name>
<price>60.0</price>
</book>
</books>
public class JDomParse {
2 public JDomParse(){
3 String xmlpath="library.xml";
4 SAXBuilder builder=new SAXBuilder(false);
5 try {
6 Document doc=builder.build(xmlpath);
7 Element books=doc.getRootElement();
8 List booklist=books.getChildren("book");
9 for (Iterator iter = booklist.iterator(); iter.hasNext();) {
10 Element book = (Element) iter.next();
11 String email=book.getAttributeValue("email");
12 System.out.println(email);
13 String name=book.getChildTextTrim("name");
14 System.out.println(name);
15 book.getChild("name").setText("alterrjzjh");
16
17 }
18
19 XMLOutputter outputter=new XMLOutputter();
20 outputter.output(doc,new FileOutputStream(xmlpath));
21
22 } catch (JDOMException e) {
23 e.printStackTrace();
24 } catch (IOException e) {
25 e.printStackTrace();
26 }
27 }
28 public static void main(String[] args) {
29 new JDomParse();
30 }
31}(6)取得元素的属性:
String email=book.getAttributeValue("email");
取得元素book的属性名为“email”的属性值。
本来本贴发在flex版的,可惜那里没有兄弟回答,现在这里这么多朋友帮忙很感谢,请知道的朋友多给意见