0

At the moment we are trying to get the Innertext from a XMLElement where the attribute is EAN. The only problem is that the XMLElements have the attribute name dt:dt, which can't be found.

We have an XML Schema for this, but how can we import this schema?

<custom-attribute dt:dt="string" name="EAN">8152210266584</custom-attribute>

We want the EAN code inside this XMLElement.

And the structure is

Product -> Custom-attributes -> Custom-attribute

We have tried to use SelectSingleNodes and LINQ but they only show the elements where there is no dt:dt attribute

mariodelta
  • 53
  • 6
  • 1
    Please post a [mcve] which we can run – canton7 Apr 26 '22 at 09:38
  • XmlNodeList value = productfile.SelectNodes("//custom-attributes/custom-attribute[@name='EAN']"); – mariodelta Apr 26 '22 at 09:41
  • 2
    "The name 'productfile' does not exist in the current context". I mean [edit] your question to include a *full* working example which we can copy/paste, and it runs and reproduces your problem straight away, without having to guess what else you're doing. For example, on https://dotnetfiddle.net . Please read [ask] – canton7 Apr 26 '22 at 09:42
  • [LINQ to XML](https://learn.microsoft.com/en-us/dotnet/standard/linq/linq-xml-overview) may be useful –  Apr 26 '22 at 09:48
  • did you try `GetAttribute`? – Patrick Beynio Apr 26 '22 at 13:25
  • What is the namespace associated with the namespace prefix `dt`? Somewhere in the scope of the element `` there will be an `xmlns:dt="some-namespace-URI"`. What is some-namespace-URI? – dbc May 07 '22 at 13:06

0 Answers0