Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Finding an entry where I have two values each in different nodes

$
0
0

Hi

Can I do this with one XPath? If I have "layer1" and "layer2" ....

Layers/Layer[@Name=\"layer1\"]  <---- This has to be true. But also ....

Layers/Layer/SnapNames/SnapName[@Name=\"layer2\"] <---- This has to be true

I did it like this:

                                    // Find main node
                                    XmlNode nodeLayer = xmlOrbis.SelectSingleNode(String.Format("Layers/Layer[@Name=\"{0}\"]", strLayer));
                                    if(nodeLayer != null)
                                    {
                                        String strLayer2 = m_dictLayers[pSegment2.layerID];
                                        XmlNode nodeLayer2 = xmlOrbis.SelectSingleNode(String.Format("SnapsNames/SnapName[@Name=\"{0}\"]", strLayer2));
                                        if(nodeLayer2 == null)
                                        {
                                        }
                                    }

Can I simplify it into one call? Something like:

XmlNode nodeLayer = xmlOrbis.SelectSingleNode(String.Format("Layers/Layer[@Name=\"{0}\"]/SnapNames/SnapName[@Name=\"{1}\"]", strLayer, strLayer2));

I don't know if that is viable ...

Andrew





Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>