[Gambas-user] Reading XML Attributes.
Antonio Cassidy
nino at ...2569...
Wed Mar 30 21:27:01 CEST 2011
Im getting a step closer, if i use the following:
FOR EACH node1.Attributes
PRINT node1.name
NEXT
I get the following:
-78,F8:DB:7F:78:34:61,PJ-WIRELESS5,None,0
wireless-network
wireless-network
wireless-network
wireless-network
-79,F8:DB:7F:79:27:36,PJ-WIRELESS5,None,0
There are 4 attributes in the node so i know its enumerating properly i just
cant seem to print out the attributes names, and values.
On Wed, Mar 30, 2011 at 7:23 PM, Antonio Cassidy <nino at ...2569...> wrote:
> Hi Caveat
>
> Would it be possible to nab a copy of the project.
>
> The following looks to be what i need to use with my current code:
>
> http://64.128.110.55/help/comp/gb.xml/.xmlnodeattributes?v3&en
>
> the high level explanation makes sense however im having issues actually
> using .xmlnodeattributes im a little out of my depth!
>
>
> On Wed, Mar 30, 2011 at 6:44 PM, Caveat <Gambas at ...1950...> wrote:
>
>> Hi Antonio
>>
>> I think this is the result you're looking for:
>>
>>
>> *******************************************************************************************
>> Get the Attribute "type" from the path wireless-network
>> Using full path: /wireless-network
>> Attribute key: number
>> Attribute key: type
>> infrastructure
>>
>> ****************************************************************************************
>>
>>
>> Using the general purpose xml editor I'm developing, you only need 3
>> lines of code to get your type attribute:
>>
>> parserToModel.parseInputFile("wireless-network.xml")n
>> rewriter = NEW XMLRewriter(parserToModel.getModel())
>> PRINT rewriter.getAttribute("/wireless-network", "type")
>>
>> I posted the project on this mailing list a while back. The code you
>> need would appear to be something like this (last 3 or 4 lines get the
>> attributes):
>>
>> IF reader.Node.Type = XmlReaderNodeType.Element THEN
>> 'Logger.logMessage("Got a start element for: " & reader.Node.Name,
>> FALSE)
>> newBucket = NEW XMLContainer
>> newBucket.setNodeName(reader.Node.Name)
>> IF currentBucket = NULL THEN
>> newBucket.setPathToNode("/")
>> ELSE
>> newBucket.setPathToNode(currentBucket.getFullPath())
>> END IF
>> 'Logger.logMessage("[NODE: " & newBucket.getFullPath() & "]" " node
>> name: " & newBucket.getNodeName(), FALSE)
>> FOR EACH reader.Node.Attributes
>> newBucket.setAttribute(reader.Node.Name, reader.Node.Value)
>> NEXT
>>
>> The reader object is a standard XmlReader.
>>
>> Let me know if I need to repost the project.
>>
>> Regards,
>> Caveat
>>
>> On Wed, 2011-03-30 at 17:21 +0100, Antonio Cassidy wrote:
>> > Hi All
>> >
>> > I am trying to write a gambas application to parse kismet XML logs.
>> >
>> > I am able to parse elements and also sub elements but not the
>> attributes.
>> >
>> > My code is here:
>> > http://pastebin.com/QiX2BsHH
>> >
>> > The sample XML is here, i specifically want to get the "type" attribute
>> from
>> > the "wireless-network" element
>> > http://pastebin.com/4DGwdzYD
>> >
>> > Many thanks
>> >
>> ------------------------------------------------------------------------------
>> > Create and publish websites with WebMatrix
>> > Use the most popular FREE web apps or write code yourself;
>> > WebMatrix provides all the features you need to develop and
>> > publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
>> > _______________________________________________
>> > Gambas-user mailing list
>> > Gambas-user at lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Create and publish websites with WebMatrix
>> Use the most popular FREE web apps or write code yourself;
>> WebMatrix provides all the features you need to develop and
>> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>
More information about the User
mailing list