Ciao a tutti,
devo analizzare un file XML ma mi trovo a litigare con il parametro "xmlns"
Eccovi qui il file:
<?xml version="1.0"?>
<GetMatchingProductForIdResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">
<GetMatchingProductForIdResult Id="7321958033456" IdType="EAN" status="Success">
<Products xmlns:ns2="http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd">
<Product>
<Identifiers>
<MarketplaceASIN>
<MarketplaceId>APJ6JRA9NG5V4</MarketplaceId>
<ASIN>B0016GM816</ASIN>
</MarketplaceASIN>
</Identifiers>
<AttributeSets>
<ns2:ItemAttributes xml:lang="it-IT">
<ns2:AspectRatio>1.85:1</ns2:AspectRatio>
<ns2:Binding>DVD</ns2:Binding>
<ns2:Brand>Warner Home Video</ns2:Brand>
<ns2:Creator Role="Attore">Giuseppe Battiston</ns2:Creator>
<ns2:Creator Role="Regista">Silvio Soldini</ns2:Creator>
<ns2:Format>DVD</ns2:Format>
<ns2:ListPrice>
<ns2:Amount>15.25</ns2:Amount>
<ns2:CurrencyCode>EUR</ns2:CurrencyCode>
</ns2:ListPrice>
<ns2:ProductGroup>DVD</ns2:ProductGroup>
<ns2:PublicationDate>2012-01-01</ns2:PublicationDate>
<ns2:Title>Giorni e nuvole</ns2:Title>
</ns2:ItemAttributes>
</AttributeSets>
</Product>
</Products>
</GetMatchingProductForIdResult>
</GetMatchingProductForIdResponse>
Per poter leggere i dati devo fare così:
Dim xmlTxt = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Desktop & "\amazon.xml")
xmlTxt = xmlTxt.Replace(" xmlns=""http://mws.amazonservices.com/schema/Products/2011-10-01""", "")
Dim xmlDoc As New XmlDocument
xmlDoc.LoadXml(xmlTxt)
Dim product = xmlDoc.SelectSingleNode("/GetMatchingProductForIdResponse/GetMatchingProductForIdResult/Products/Product")
cioè devo togliere quel parametro xmlns, ma vorrei capire come fare senza doverlo togliere.
Poi ovviamente avrò il problema anche con il <ns2:.......> ma questo lo vedrò dopo
Grazie
Sergio