Fwd: problem parsing msproject xml

"Dan Trevino" <[email protected]>
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
Thanks I tried this, but:

>>> prjdoc = xml.dom.minidom.parse('prj.xml')
>>> tasklist = prjdoc.getElementsByTagName('Task')
>>> for task in tasklist:
...     taskname = task.getElementsByTagName('Name')
...     print taskname.firstChild.data
...
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
AttributeError: 'NodeList' object has no attribute 'firstChild'
>>>

On 7/31/07, Bill Kinnersley <[email protected]> wrote:
> Never used DOM and never written a line of Python, but maybe even I know
> the answer to this one!
>
> The minidom documentation suggests that instead of
>
>         print taskname
>
> you should be saying
>
>         print taskname.firstChild.data
>
>
> Bill K
>
> Dan Trevino wrote:
> > I'm trying to parse project xml.  The main thing i'm trying to get at
> > is the task name, which is basically in this structure:
> > <Task>
> >   <UID>1</UID>
> >   <Name>do step 1</Name>    <-- i want the text from here
> > ...
> > </Task>
> > <Resource>
> >   <Name>John Doe</Name>
> > ...
> > </Resource>
> >
> > I'm having difficulty figuring out which methods to use to access the
> > data.  I cant get to "Name" directly because it is used also for
> > project resources....so I need the task name specifically.  Where do I
> > go from here:
> >
> > ==============================
> >>>> prjdoc = minidom.parse('prj.xml')
> >>>> tasklist = prjdoc.getElementsByTagName("Task")
> >>>> for task in tasklist:
> > ...     taskname = task.getElementsByTagName('Name')
> > ...     print taskname
> > ...
> > []
> > [<DOM Element: Name at 0x5e89a08>]
> > [<DOM Element: Name at 0x5e99ad0>]
> > [<DOM Element: Name at 0x5eb00d0>]
> > [<DOM Element: Name at 0x5efb698>]
> > [<DOM Element: Name at 0x5f0dc60>]
> >
> > ================================
> > TIA,
> > dan
>
> _______________________________________________
> XML-SIG maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/xml-sig
>
_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.