chenyunguiMilook / SwiftyXML

The most swifty way to deal with XML data in swift 5.
MIT License
103 stars 28 forks source link

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

Open corey-williams opened 5 years ago

corey-williams commented 5 years ago
<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>
alexsteinerde commented 4 years ago

For me it worked if I use something like the following:

let color0 = xml.product.catalog_item.price.xml?.value = "50"