Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

could anyone explain why based on the following I get both elements returned when I only want to return the path element??

 


<?xml version="1.0" encoding="utf-8" ?> 
<!ELEMENT config (path, sysadmin)>
<!ELEMENT path (#PCDATA)>
<!ELEMENT sysadmin (#PCDATA)>

 


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Config PUBLIC "SYSTEM" "xConfig-DTD.xml">
<Config>
 <path>C:\Documents and Settings\paul\My Documents\project.mdb</path>
 <sysadmin>d.p.hooper</sysadmin>
</Config>

 


       Try

           Dim strDocument As String = Environment.GetFolderPath(Environment.SpecialFolder.System) & "\xConfig.xml"

           Dim xPathDocument As XPathDocument = New XPathDocument(strDocument)

           Dim xPathNav As XPathNavigator = xPathDocument.CreateNavigator

           xPathNav.MoveToRoot()

           Dim xPathNodeIterate As XPathNodeIterator = xPathNav.Select("descendant::config/path")

           xPathNodeIterate.MoveNext()

           strPath = xPathNodeIterate.Current.Value

       Catch objException As Exception

           ShowError("Location:   Class frmMain" & ControlChars.CrLf & ControlChars.CrLf & _
                     "Procedure:  SetUserPref" & ControlChars.CrLf & ControlChars.CrLf & "Error Text: " & _
                     objException.Message)

           Return False

      End Try

My website

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...