Giter VIP home page Giter VIP logo

swiftyxml's People

Contributors

andyj-at-aspin avatar chenyunguimilook avatar skjiisa avatar stuffmc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftyxml's Issues

Using your sample code, how would you modify an existing value? Like changing the price from 42.50 to 50

<catalog>
	<product description="Cardigan Sweater" product_image="cardigan.jpg" >
		<catalog_item gender="Men's" >
			<item_number>QWZ5671</item_number>
			<price>39.95</price>
			<size description="Medium" >
				<color_swatch image="red_cardigan.jpg" >Red</color_swatch>
				<color_swatch image="burgundy_cardigan.jpg" >Burgundy</color_swatch>
			</size>
			<size description="Large" >
				<color_swatch image="red_cardigan.jpg" >Red</color_swatch>
				<color_swatch image="burgundy_cardigan.jpg" >Burgundy</color_swatch>
			</size>
		</catalog_item>
		<catalog_item gender="Women's" >
			<item_number>RRX9856</item_number>
			<price>42.50</price>
			<size description="Small" >
				<color_swatch image="red_cardigan.jpg" >Red</color_swatch>
				<color_swatch image="navy_cardigan.jpg" >Navy</color_swatch>
				<color_swatch image="burgundy_cardigan.jpg" >Burgundy</color_swatch>
			</size>
		</catalog_item>
	</product>
</catalog>

How to access children with hyphen in its name

My Xml has a lot of values separated by hyphen like "display-name" or "item-id", but I can't figure ii out on how to access to its values.

If I use the readme instructions like this:

let name = xml.channel.0.display-name.string
Binary operator '-' cannot be applied to operands of type 'XMLSubscriptResult' and 'String'

Is there any way to achieve this ?

Xcode 9 Swift 4.0

import SwiftyXML Module compiled with Swift 3.1 cannot be imported in Swift 4.0

Construct XML not work correctly

let newXML = LocalDataModelXML.newTasksXML!
            newXML.addChild(XML(string: tasks))

If construct XML from existing XML new tag added new tag and not parse new tag.
After parse final xml view one first tag

<Doc StatusDoc="new" >
	<clientsTasks>
		<clientTask description="Dsdsd" persone="Гребенкина Анастасия" date="1562290361.0" id_client="000006383" name="Dodd’s" />
	</clientsTasks>
	<clientsTasks>
		<clientTask description="Dsdsd" date="1562463999.0" id_client="000006383" persone="Гребенкина Анастасия" name="dsdsdds" />
	</clientsTasks>
	<clientsTasks>
		<clientTask name="dsdsdds" description="Dsdsd" date="1562463999.0" id_client="000006383" persone="Гребенкина Анастасия" />
	</clientsTasks>
	<clientsTasks>
		<clientTask date="1562463999.0" persone="Гребенкина Анастасия" description="Dsdsd" id_client="000006383" name="dsdsdds" />
	</clientsTasks>
	<clientsTasks>
		<clientTask id_client="000006383" name="dsdsdds" date="1562463999.0" persone="Гребенкина Анастасия" description="Dsdsd" />
	</clientsTasks>
	<clientsTasks>
		<clientTask persone="Гребенкина Анастасия" date="1562207178.0" description="dsdsd" id_client="000006383" name="dsdsd" />
	</clientsTasks>
	<clientsTasks>
		<clientTask date="1562121435.0" description="Hello" persone="Казакова Анастасия" name="test update view" id_client="000006383" />
	</clientsTasks>
</Doc>

Manual Installation

CocoaPods and Carthage are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.

It would be cool to add the Manual installation guide in your README.md. You can take a look at my iOS Readme Template to see how you can do it.

Characters are removed before first non-ascii character

In the attached xml response (Google geocode response.pdf, this is the response from url https://maps.googleapis.com/maps/api/geocode/xml?&latlng=63,10), the value of xml["result"][0]["address_component"][3]["short_name"].stringValue is "ør-Trøndelag" (xml is the value of XML(data: data) from the response (using Alamofire)). The correct response should be "Sør-Trøndelag". Thus, the first S is missing. I have also seen other examples where multiple (all) characters before the first non-ascii character is removed in the stringValue.

For make true XML need in the loop get all value and fix then.

For make true XML need in the loop get all value and fix then.
Example:
let newXMLHead: XML = XML(name: "clients")
let usersXML: [XML] = memoryXML!["#clients"]["client"].xmlList!
for value in usersXML {
let newXML: XML = XML(name: "clients")
for (key, subValue) in value.attributes {
newXML.addAttribute(name: key, value: subValue.percentEscapeString())
}
newXMLHead.addChild(newXML)
}

Where
extension String {
func percentEscapeString() -> String {
return self
.replacingOccurrences(of: "&", with: "&amp;")
.replacingOccurrences(of: """, with: "&quot;")
.replacingOccurrences(of: "'", with: "&#39;")
.replacingOccurrences(of: ">", with: "&gt;")
.replacingOccurrences(of: "<", with: "&lt;")
}
}

Originally posted by @kiri11ko in #8 (comment)

XML class public properties mask child XML elements with the same name

The public properties of the XML class (name, attributes, value and children) can mask child XML elements with the same element name when attempting to use DynamicMemberLookup to traverse the XML chain.

A real-world occurrence of this issue is that full traversal of the xml tree of the GPX file format (https://en.wikipedia.org/wiki/GPS_Exchange_Format) using DynamicMemberLookup is impossible because of child elements named as "name" in the wptType, rteType, trkType and personType elements.

I have created a pull request for a suggested fix that renames the public properties of the XML class by adding xml... as a prefix to the property name.

Read value by attributes?

Hey,

First of all, I must say this is a great control.

But I would like to ask is there anyway to access the value by using attributes? Like in your example,
let color0 = xml["product"]["catalog_item"]["size"]["color_swatch"][1].string //"Burgundy"

Can I access the value "Burgundy" without using the number (1 in this case), but with the file name "burgundy_cardigan.jpg"? Thanks!

How do you delete a child?

In your example xml, how would you delete a complete tag: for example everything between <catalog_item> and </catalog_item> including the starting and ending tags? I want to replace a complete item with an updated version.

Many thanks

Robert

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.