python中documentelement_document、element、node方法
document方法:
getElementById(id) 返回指定结点的引用
getElementsByTagName(name) 返回文档中所有匹配的元素的集合
createElement(name) 创建指定类型的新结点
createTextNode(text) 创建一个纯文本结点
element方法:
getAttribute(id) 返回指定属性的值
setAttribute(id,value) 给属性赋值
removeAttribute(id) 移除指定属性和它的值
getElementsByTagName(name) 返回结点内所有匹配的元素的集合
node方法:
appendChild(child) 给指定结点添加一个新的子结点
removeChild(child) 移除指定结点的子结点
replaceChild(newChild,oldChild) 替换指定结点的子结点
insertBefore(newChild,refChild) 在同一层级的结点前面插入新结点
hasChildNodes() 如果结点有子结点则返回true
node属性:
nodeName 以字符串的格式存放结点的名称
nodeType 以整型数据格式存放结点的类型
nodeValue 以可用的格式存放结点的值
parentNode 指向结点的父结点的引用
childNodes 指向子结点的引用的集合
firstChild 指向子结点结合中的第一个子结点的引用
lastChild 指向子结点结合中的最后一个子结点的引用
document方法: getElementById(id) 返回指定结点的引用 getElementsByTagName(name) 返回文档中所有匹配的元素的集合 createElement(name) 创建指定类型的新结点 createTextNode(text) 创建一个纯文本结点 element方法: getAttribute(id) 返回指定属性的值 setAttribute(id,value) 给属性赋值 removeAttribute(id) 移除指定属性和它的值 getElementsByTagName(name) 返回结点内所有匹配的元素的集合 node方法: appendChild(child) 给指定结点添加一个新的子结点 removeChild(child) 移除指定结点的子结点 replaceChild(newChild,oldChild) 替换指定结点的子结点 insertBefore(newChild,refChild) 在同一层级的结点前面插入新结点 hasChildNodes() 如果结点有子结点则返回true node属性: nodeName 以字符串的格式存放结点的名称 nodeType 以整型数据格式存放结点的类型 nodeValue 以可用的格式存放结点的值 parentNode 指向结点的父结点的引用 childNodes 指向子结点的引用的集合 firstChild 指向子结点结合中的第一个子结点的引用 lastChild 指向子结点结合中的最后一个子结点的引用