Results 1 to 2 of 2

Thread: xml to container (PYTHON)

  1. #1
    Join Date
    Aug 2009
    Beans
    105

    xml to container (PYTHON)

    i am reading an xml file and need to store the contents (elements) of that to a container.

    mapping = {}
    titleTuple =[]
    i=0
    for node in doc.getElementsByTagName("book"):
    isbn = node.getAttribute("isbn")
    L = node.getElementsByTagName("title")
    for node2 in L:
    title = ""
    print title
    for node3 in node2.childNodes:
    if node3.nodeType == Node.TEXT_NODE:
    title += node3.data
    print "title %s,node3.data %s"%(title,node3.data)
    titleTuple.append[node3.data]
    mapping[isbn] = title

    I am confused which container to be used and how.
    I tried set "titleTuple.append[node3.data]" but it gives an error
    'builtin_function_or_method' object is unsubscriptable

    i am new to python so kindly help me on this.

  2. #2
    Join Date
    Nov 2004
    Beans
    560
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: xml to container (PYTHON)

    Code:
    titleTuple.append(node3.data)
    round brackets for functions.
    Last edited by surfer; October 8th, 2010 at 11:23 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •