0

I'm trying to select a node by its attribute name, but my selectors return nothing.

XML

<?xml version="1.0" encoding="utf-8"?>
<products>
    <product ID="10036218">
    <name>TEST</name>
    <price currency="EUR">8.95</price>
    <categories>
        <category path="Feestartikelen">Feestartikelen</category>
    </categories>
    <properties>
        <property name="fromPrice">
            <value>8.95</value>
        </property>
        <property name="gender">
            <value></value>
        </property>
        <property name="deliveryCosts">
            <value>3.95</value>
        </property>
        <property name="model">
            <value>Balloons</value>
        </property>
    </properties>
    <variations/>
    </product>  
</products> 


Dim nodeList As XmlNodeList = root.SelectNodes("/products/product")

nodelist.Count = 530 here, so I'm getting results. Next I tried both properties/property/@model/value and properties/property/@model as values to select the node. Both return nothing.

For Each node In nodeList
    If node.SelectSingleNode("properties/property/@model/value") IsNot Nothing Then

    End If
Next node

What's wrong with my expressions?

1 Answer 1

1

This should get you the node by attribute name:

For Each node In nodeList
    If node.SelectSingleNode("properties/property[@name='model']/value") IsNot Nothing Then

    End If
Next node
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.