新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     >>W3CHINA.ORG讨论区<<     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论DOM, SAX, XPath等。
    [返回] W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWLXML.ORG.CN讨论区 - XML技术『 DOM/SAX/XPath 』 → 怎样设置节点的属性? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 3244 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 怎样设置节点的属性? 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     junge_003 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:7
      积分:76
      门派:XML.ORG.CN
      注册:2006/3/2

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给junge_003发送一个短消息 把junge_003加入好友 查看junge_003的个人资料 搜索junge_003在『 DOM/SAX/XPath 』的所有贴子 引用回复这个贴子 回复这个贴子 查看junge_003的博客楼主
    发贴心情 怎样设置节点的属性?

    一个节点具有多个属性比如<node name="node" id="2">
    这样的节点属性怎么设置啊?
    用哪个方法?

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2006/5/19 10:53:00
     
     flyfoxs 帅哥哟,离线,有人找我吗?
      
      
      威望:5
      等级:研一(Artificial Intelligence期期不放过)
      文章:550
      积分:3935
      门派:XML.ORG.CN
      注册:2005/1/8

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给flyfoxs发送一个短消息 把flyfoxs加入好友 查看flyfoxs的个人资料 搜索flyfoxs在『 DOM/SAX/XPath 』的所有贴子 引用回复这个贴子 回复这个贴子 查看flyfoxs的博客2
    发贴心情 
    如果是用java语言的话,

    Element提供了如下方法,不过由于DOM是一个标准,很多语言都支持到了2级别,操作起来应该是一样的。


    public void setAttribute(String name,
                             String value)
                      throws DOMException
    Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute.
    To set an attribute with a qualified name and namespace URI, use the setAttributeNS method.

    Parameters:
    name - The name of the attribute to create or alter.
    value - Value to set in string form.
    Throws:
    DOMException - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.
    NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

    ----------------------------------------------
    存在即是被搜索!

    BLOG =>  http://www.OpenJ.cn

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2006/5/19 12:58:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 DOM/SAX/XPath 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/7/30 9:57:36

    本主题贴数2,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    50.781ms