Closed Moustafa2050 closed 4 years ago
Hi @Moustafa2050 - I'm not sure what happened, but I'm not seeing any code snippets or anything... can you clarify your question?
Sorry for that and i don’t know what happened ,
my question is :
if i have this element in XML format :
<Fee CurrencyCode="USD" Amount="733.11" Purpose="22"></Fee>
how can i check if element " Fee " has an attribute which name as example is " Amount " or not?
I'm guessing you have multiple elements that are called Fee
but not all have Amount
?
Check out this small sample:
let issueXML = """
<Fees>
<Fee CurrencyCode="USD"></Fee>
<Fee CurrencyCode="USD" Amount="733.11" Purpose="22"></Fee>
</Fees>
"""
let issue = SWXMLHash.parse(issueXML)
let found = issue["Fees"]["Fee"].all.filter { idx in idx.element?.attribute(by: "Amount") != nil }
// only prints the one with the Amount attribute
print(found)
Does this help?
yes , that all i need,
thank you so much .
for example i have this element :
if i want to know if element Fee is contain the attribute Amount or not. how can get this?