初学者提问,通过js改变下面的属性值

菜鸟提问,通过js改变下面的属性值
<svg width="200" height="250">  
  <rect id="x" x="10" y="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>  
  <rect x="60" y="10" rx="10" ry="10" width="30" height="30" stroke="black" fill="transparent" stroke-width="5"/>  
</svg> 
比如这样一段html,我如何能通过js,去改变这个id为x,的rect的长,宽,高什么的啊
------解决方案--------------------
document.getElementsByTagName("svg")[0].children[0].setAttribute("id", "xxx")
w = document.getElementsByTagName("svg")[0].children[0].getAttribute("width")
------解决方案--------------------
引用:
document.getElementsByTagName("svg")[0].children[0].setAttribute("id", "xxx")
w = document.getElementsByTagName("svg")[0].children[0].getAttribute("width")


同意
------解决方案--------------------
document.getElementsByTagName("svg")[0].children[0].setAttribute("id", "xxx")
w = document.getElementsByTagName("svg")[0].children[0].getAttribute("width")