selectsinglenode

System.Xml.XPath.XPathException: Expression must evaluate to a node-set when executing SelectSingleNode("//(artist|author)")

Can somebody explain me why is this not working? I'm executing XmlNode xmlNode = xmlDocument.SelectSingleNode("//(artist|author)"); and I get System.Xml.XPath.XPathException: Expression must evaluate to a node-set. but this works and does not raise the exception even when there are many artist nodes XmlNode xmlNode = xmlDocument....

Why is SelectSingleNode returning null?

I'm working with an XML document that contains a structure that looks similar to this: <MT> <Events> <event id="1"> <field name="blah" value="a_value" type="atype" /> . . . </event> </Events> </MT> I'm currently loading this from a file into an XML document in this fashion: XmlDocument xdoc = ne...

Using XPath in SelectSingleNode: Retrieving individual element from XML if it's present.

My XML looks like : <?xml version=\"1.0\"?> <itemSet> <Item>one</Item> <Item>two</Item> <Item>three</Item> .....maybe more Items here. </itemSet> Some of the individual Item may or may not be present. Say I want to retrieve the element <Item>two</Item> if it's present. I've tried the following XPaths (in C#...

Null returned when selecting a node in XML document

New to XML. I have a 3rd party webservice that supplies an XML document that I have to update the element values and pass back. The core issue issue is I get an NullReferenceException error when calling the node.RemoveAll() method in the code below. I'm calling the RemoveAll() method because each element has the xsi:nil attribute whe...

C # SelectSingleNode - Can it be used recursively?

As in, if I have an XML Document <root a="value"> <item name="first"> x <foo name = "firstgrandchild">There is nothing here</foo> y <foo name = "secondgrandchild">There is something here</foo> </item> <item name="second"> xy <foo/> ab </item> </root> I want to fi...

Backslash SelectSingleNode Escape

In Javascript I have an XML DOM. I am trying to select a node within the DOM by using SelectSingleNode. Something like cell.SelectSingleNode(stuff [@attrjunk = 'MATCH']). So what I want to match on has a backslash . What do I replace the MATCH with to match on abc\xyz?? I've tried abc\xyz and abcxyz but neither seems to work unfortu...

Selectsinglenode in IXMLDOMElement?

can i perform select single node from IXMLDOMElement ,if its possible give me one example for that using MSXML ...

Parsing XML: Colon in my element causes XPath to miss it

I have an XML document that I load in and try to search with XPath. The root node in this file is <t:Transmission xmlns:t='urn:InboundShipment'> and the file end is properly closed with </t:Transmission>. My problem is that I cannot walk the tree without using a descendant axis. In other words, I can do: SelectSingleNode("//Transactio...

SelectSingleNode always returns null?

Taking this simplifed example of my XML: <?xml version="1.0"?> <message xmlns="http://www.mydomain.com/MyDataFeed" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mydomain.com/MyDataFeed https://secure.mydomain/MyDataFeed/myDataFeed.xsd" requestId="13898" status="1"> <error>Invalid Login</error> </me...

HTMLAgilityPack ChildNodes index works, named node does not

I am parsing an XML API response with HTMLAgilityPack. I am able to select the result items from the API call. Then I loop through the items and want to write the ChildNodes to a table. When I select ChildNodes by saying something like: sItemId = dnItem.ChildNodes(0).innertext I get the proper itemId result. But when I try: sItemId...

XmlDocument SelectSingleNode of improperly formed XML

I have a XmlDocument which is not properly formed <library> <dept> <books></books> <language></language> </dept> <dept> <lecturer></lecturer> </dept> </library> I want to do a XmlDocument.SelectSingleNode for 'lecturer' tag. When I select ChildNodes of <library> tag, I get only <books> and <language> but not <lec...

Can DocumentNode.SelectSingleNode skip selection of anchor tag events?

Given the following... HtmlNode myDiv = doc.DocumentNode.SelectSingleNode("//div[@id='someid']"); ...where the resulting myDiv.InnerHtml contains: <span>...other content I want to consume...</span> <a href="http://www.somewhere.com" onmousedown="return somefunc('random','parm','values','SHXA213')">Click Me</a> <span>...and more conte...

selectSingleNode works but not selectNodes

Javascript: var req=xmlDoc.responseXML.selectSingleNode("//title"); alert(req.text); as expected, returns the text of the first "title" node. but this var req=xmlDoc.responseXML.selectNodes("//title"); alert(req.text); returns "undefined." The following: var req=xmlDoc.responseXML.selectNodes("//title").length; alert(req); ret...

Function RemoveChild(XmlNode node) failed in C#

Hello, When I try to remove some of my child element with RemoveChild(). But throw exception. I attached my code below. nodeName = doc.SelectSingleNode("//Equipment//DataCollections//EnabledIDs//MyID[@id='" + attrValue + "']"); // Found the nodeName successfully druing run time. doc.DocumentElement.RemoveChild(nodeName); ...

XPath Query always returns NULL only on some queries in SingleNodeSelect

<?xml version="1.0" encoding="utf-16"?> <users> <user number="0772247157"> <step stepnumber="1">complete</step> <step stepnumber="2">complete</step> <step stepnumber="3">complete</step> </user> <user number="0772247158"> <step stepnumber="1">complete</step> <step stepnumber="2">complete</step> </user> <user ...

SelectSingleNode returns null

So i have an XML document that looks like this: <?xml version="1.0" encoding="UTF-8"?> <gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"&gt; <gesmes:subject>Reference rates</gesmes:subject> <gesmes:Sender> <gesmes:name>European Central Bank</gesme...