Results 1 to 3 of 3

Thread: SelectNodes issue

  1. #1

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    SelectNodes issue

    At the moment I have a workaround, but this really needs solving because this is going to increase the complexity of my application.

    That said, the problem:

    Source XML:
    Code:
    <ShowParty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:Example="http://www.example.com" revision="8.0" xmlns="http://www.openapplications.org/oagis">
    	<ApplicationArea>
    		<CreationDateTime>1900-10-01T14:29:30-07:00</CreationDateTime>
    	</ApplicationArea>
    	<DataArea>
    		<Show confirm="Never" totalRecordCount="4" />
    			<Party>
    				<Business>
    					<Name>Business One</Name>
    					<UserArea>
    						<Example:Telephone>5555555555</Example:Telephone>
    					</UserArea>
    				</Business>
    			</Party>
    			<Party>
    				<Business>
    					<Name>Business Two</Name>
    					<UserArea>
    						<Example:Telephone>2222222222</Example:Telephone>
    					</UserArea>
    				</Business>
    			</Party>
    	</DataArea>
    </ShowParty>
    Fed in to my function, I amy trying to select the value of:
    DataArea/Party/Business/Name

    Here is my code:
    Code:
    			public void GetResults(string SourceXML, stringSearchNode)
    			{
    				XmlDocument doc = new XmlDocument();
    				System.IO.MemoryStream objDoc = new System.IO.MemoryStream(GetByteArray(SourceXML));
    				doc.Load(objDoc);
    				System.Xml.XmlNamespaceManager oNS = new System.Xml.XmlNamespaceManager(doc.NameTable);
    				oNS.AddNamespace("Example", "http://www.example.com");
    
    				System.Xml.XmlNodeList oNL;
    				oNL = doc.DocumentElement.SelectNodes(SearchNode, oNS);
    				for(int j = 0 ; j < oNL.Count ; j++)
    				{
    					Debug.WriteLine(oNL[j].InnerText);
    				}
    			}
    
    
    
    			public static byte[] GetByteArray(string sIn)
    			{
    				byte[] oTmp = new byte[sIn.Length];
    				for(int i = 0 ; i < sIn.Length ; i++)
    				{
    					oTmp[i] = (byte)(sIn.Substring(i, 1).ToCharArray(0, 1)[0]);
    				}
    				return oTmp;
    			}
    Well, it doesn't select any nodes at all if I call the function like this:
    GetResults(sSourceXML, "DataArea/Party/Business/Name") /* sSourceXML is the original XML as a string */

    But if I call it like this, it does work:
    GetResults(sSourceXML, "*[name()='DataArea']/*[name()='Party']/*[name()='Business']/*[name()='Name']")

    But that second method was after a half a day working at this issue and is basically a hack. What I discovered was that I was able to select any node I wanted if I used the '*' wildcard to select nodes, but as soon as I was specific about a node's name, it would not return any nodes, ever.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  2. #2

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: SelectNodes issue

    Bumpity umpity
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: SelectNodes issue

    Periodic Bump (this is important to me and not resolved.)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width