Re: Does XML (AEXML) node exist?

2017-04-05 Thread Eric E. Dolecki
I tried this and it seems to work - but does it look sound?

let theVolume = xmlDoc.root["volumeUpdated"].first
if theVolume != nil {
print(">> We have a volume update. \(String(describing: theVolume!))")
}

On Wed, Apr 5, 2017 at 10:56 AM Eric E. Dolecki  wrote:

> I'm using AEXML and I have some return XML from a WebSocket. I want to
> check if the return XML contains a node or not. In this way, I know what
> kind of data I'm receiving.
>
> 
> 
> 
>
> What's the best way to check if that volumeUpdated node exists? It has no
> attributes or value.
>
> I tried this (AEXMLElement is non-optional):
>
> let theVolume = xmlDoc.root["volumeUpdated"]
> if theVolume != nil {
> print(">> We have a volume update. \(theVolume)")
> }
>
> But I get a "comparing non-optional value of type 'AEXMLElement' to nil
> always returns true.
>
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Does XML (AEXML) node exist?

2017-04-05 Thread Eric E. Dolecki
I'm using AEXML and I have some return XML from a WebSocket. I want to
check if the return XML contains a node or not. In this way, I know what
kind of data I'm receiving.





What's the best way to check if that volumeUpdated node exists? It has no
attributes or value.

I tried this (AEXMLElement is non-optional):

let theVolume = xmlDoc.root["volumeUpdated"]
if theVolume != nil {
print(">> We have a volume update. \(theVolume)")
}

But I get a "comparing non-optional value of type 'AEXMLElement' to nil
always returns true.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com