Hi, Santiago:

Yes, your e-mail has been received. I'm sorry, I can't solve your question.

Regards.

Eva

--- El mar, 16/4/13, santiago gil <sg.c...@gmail.com> escribió:

De: santiago gil <sg.c...@gmail.com>
Asunto: Re: [R] Problem with handling of attributes in xmlToList in XML package
Para: r-help@r-project.org
Fecha: martes, 16 de abril, 2013 20:49

Are my emails getting through?

2013/4/14 santiago gil <sg.c...@gmail.com>:
> Hello all,
>
> I have a problem with the way attributes are dealt with in the
> function xmlToList(), and I haven't been able to figure it out for
> days now.
>
> Say I have a document (produced by nmap) like this:
>
>> mydoc <- '<host starttime="1365204834" endtime="1365205860"><status 
>> state="up" reason="echo-reply" reason_ttl="127"/>
>     <address addr="XXX.XXX.XXX.XXX" addrtype="ipv4"/>
>     <ports><port protocol="tcp" portid="135"><state state="open"
> reason="syn-ack" reason_ttl="127"/><service name="msrpc"
> product="Microsoft Windows RPC" ostype="Windows" method="probed"
> conf="10"><cpe>cpe:/o:microsoft:windows</cpe></service></port>
>     <port protocol="tcp" portid="139"><state state="open"
> reason="syn-ack" reason_ttl="127"/><service name="netbios-ssn"
> method="probed" conf="10"/></port>
>     </ports>
>     <times srtt="647" rttvar="71" to="100000"/>
>     </host>'
>
> I want to store this as a list of lists, so I do:
>
> mytree<-xmlTreeParse(mydoc)
> myroot<-xmlRoot(mytree)
> mylist<-xmlToList(myroot)
>
> Now my problem is that when I want to fetch the attributes of the
> services running of each port, the behavior is not consistent:
>
>> mylist[["ports"]][[1]][["service"]]$.attrs["name"]
>    name
> "msrpc"
>> mylist[["ports"]][[2]][["service"]]$.attrs["name"]
> Error in trash_list[["ports"]][[2]][["service"]]$.attrs :
>   $ operator is invalid for atomic vectors
>
> I understand that the way they are dfined in the documnt is not the
> same, but I think there still should be a consistent behavior. I've
> tried many combination of parameters for xmlTreeParse() but nothing
> has helped me. I can't find a way to call up the name of the service
> consistently regardless of whether the node has children or not. Any
> tips?
>
> All the best,
>
>
> S.G.
>
> --
> -------------------------------------------------------------------------------
> http://barabasilab.neu.edu/people/gil/



-- 
-------------------------------------------------------------------------------
http://barabasilab.neu.edu/people/gil/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to