selectsinglenode

XmlDocument.SelectSingleNode and xmlNamespace issue

不问归期 提交于 2019-12-24 09:49:47
问题 I'm loading a string to an XML document that contains the following structure : <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Compile Include="clsWorker.cs" /> </ItemGroup> </Project> then im loading all into xmldocument : XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(Xml); then the following problem occurs : XmlNode Node = xmldoc.SelectSingleNode("//Compile"); //

Null returned when selecting a node in XML document

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 02:28:41
问题 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 when it is supplied to me, and if I don't remove it before updating the element value, the XML won't validate by the webservice. The XML document supplied by the 3rd

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

爷,独闯天下 提交于 2019-12-21 03:41:42
问题 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#). XMLNode node = myXMLdoc.SelectSingleNode("/itemSet[Item='two']") --- If Item two is present, then it returns me only the first element one . Maybe this query just points to the first

Why is XmlNamespaceManager necessary?

£可爱£侵袭症+ 提交于 2019-12-18 10:10:04
问题 I've come up kinda dry as to why -- at least in the .Net Framework -- it is necessary to use an XmlNamespaceManager in order to handle namespaces (or the rather clunky and verbose [local-name()=... XPath predicate/function/whatever) when performing XPath queries. I do understand why namespaces are necessary or at least beneficial, but why is it so complex? In order to query a simple XML Document (no namespaces)... <?xml version="1.0" encoding="ISO-8859-1"?> <rootNode> <nodeName>Some Text Here

Why is SelectSingleNode returning null?

*爱你&永不变心* 提交于 2019-12-17 19:44:56
问题 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 = new XmlDocument(); xdoc.Load("somefile.xml"); //Successfully loads btw However I'm running into a problem and only with this one particular document when I try to run the next line of code: xdoc

Using SelectSingleNode with XPath returns NULL

房东的猫 提交于 2019-12-11 01:05:24
问题 I trying to modify an XML file with SelectSingleNode . The structure of file is <?xml version="1.0" encoding="utf-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ProjectExtensions> <Borland.Personality>Delphi.Personality</Borland.Personality> <Borland.ProjectType>VCLApplication</Borland.ProjectType> <BorlandProject> <BorlandProject> <Delphi.Personality> <Parameters> ... </Parameters> <VersionInfo> <VersionInfo Name="IncludeVerInfo">True</VersionInfo> <VersionInfo

Select Single Node with a attribute name in vbscript

余生颓废 提交于 2019-12-07 08:21:44
问题 Have an xml file <DataSource> <localdata> <add context="Localization"> <parameter name="timeout" type="int" defaultvalue="60"/> <parameter name="address" type="string" defaultvalue="192.168.9.45" /> <parameter name="port" type="int" defaultvalue="6789"/> </add> <add context="General"> <parameter name="timeout" type="int" defaultvalue="60"/> <parameter name="address" type="string" defaultvalue="192.168.9.478" /> <parameter name="port" type="int" defaultvalue="5674"/> </add> </localdata> <

SelectSingleNode always returns null?

♀尐吖头ヾ 提交于 2019-12-05 17:42:48
问题 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> </message> I am trying to select the 'error' node using SelectSingleNode method, however using the following code it always returns NULL? XmlNode errorNode = oss

Select Single Node with a attribute name in vbscript

倾然丶 夕夏残阳落幕 提交于 2019-12-05 16:02:50
Have an xml file <DataSource> <localdata> <add context="Localization"> <parameter name="timeout" type="int" defaultvalue="60"/> <parameter name="address" type="string" defaultvalue="192.168.9.45" /> <parameter name="port" type="int" defaultvalue="6789"/> </add> <add context="General"> <parameter name="timeout" type="int" defaultvalue="60"/> <parameter name="address" type="string" defaultvalue="192.168.9.478" /> <parameter name="port" type="int" defaultvalue="5674"/> </add> </localdata> </DataSource> I need to get the element whose attribute is context="General" using vbscript I can get the top

Html Agility Pack SelectSingleNode giving always same result in iteration?

旧巷老猫 提交于 2019-12-04 17:00:15
问题 I would like the nodes in the collection but with iterating SelectSingleNode I keep getting the same object just node.Id is changing... What i try is to readout the webresponse of a given site and catch some information like values, links .. in special defined elements. int offSet = 0; string address = "http://www.testsite.de/ergebnisliste.html?offset=" + offSet; HtmlWeb web = new HtmlWeb(); //web.OverrideEncoding = Encoding.UTF8; HtmlDocument doc = web.Load(address); HtmlNodeCollection