I have a xml as follows:
<Head>
<Company>
<Props>
</Props>
<Config>
</Config>
<Products>
<Product type="Random" name="xyz">
<Property name="asd" value="asd"/>
</Product>
<Product type="Random1" name="xyz1">
<Property name="asd1" value="asd1"/>
</Product>
<Product type="Random2" name="xyz">
<Property name="asd2" value="asd2"/>
</Product>
</Products>
</Company>
</Head>
I need to extract node "Product" and its attribute "name". But (Subnode of "Product") "Property" also has attribute "name". I wrote a code as follows:
val xml = XML.loadFile("product.xml")
val names = (Head \\ Company \\ prodcuts \\ product \\ "@name").map { _.text }
But this returns a list of name of product and property both. How do i select only Product names ? Thanks