Coder Social home page Coder Social logo

Comments (4)

tyczj avatar tyczj commented on August 19, 2024

I see this problem too

from aexml.

tadija avatar tadija commented on August 19, 2024

Can you elaborate on this? Which version are you using? I'm only interested if it's the latest, and if you could please add some example in Xcode Playground perhaps?

from aexml.

ferrarop avatar ferrarop commented on August 19, 2024

It happens in the latest version.
It seems that you correctly escape the element "value", but not the attributes.

In particular, in the xmlString property, you use (escapedStringValue) for the element value, and the unescaped (value) for the attributes values.

/// Complete hierarchy of `self` and `children` in **XML** escaped and formatted String
public var xmlString: String {
    var xml = String()

    // open element
    xml += indentation(parentsCount - 1)
    xml += "<\(name)"

    if attributes.count > 0 {
        // insert attributes
        for (key, value) in attributes {
            xml += " \(key)=\"\(value)\""
        }
    }

    if value == nil && children.count == 0 {
        // close element
        xml += " />"
    } else {
        if children.count > 0 {
            // add children
            xml += ">\n"
            for child in children {
                xml += "\(child.xmlString)\n"
            }
            // add indentation
            xml += indentation(parentsCount - 1)
            xml += "</\(name)>"
        } else {
            // insert string value and close element
            xml += ">\(escapedStringValue)</\(name)>"
        }
    }

    return xml
}

Attributes are [String: String], so they can't access the escapedStringValue property of AEXMLElement.
I think you should escape attributes in the same way you do for element values, doing something similar to the escapedStringValue property.

from aexml.

tadija avatar tadija commented on August 19, 2024

Hi, escaping attribute values is added in latest version (3.0.0). Thanks for reporting this!

from aexml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.