Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 1.42 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Adding XML namespace reference in vb.net
  2. <OverallDocument>
  3.     <SetFields>
  4.         <name>Jon Doe</name>
  5.         <age>24</age>
  6.         <sex>M</sex>
  7.     </SetFields>
  8.     <FreeXML>
  9.     <!--custom xml goes here-->
  10.     </FreeXML>
  11. </OverallDocument>
  12.        
  13. <OverallDocument>
  14.     <SetFields>
  15.         <name>Jane Doe</name>
  16.         <age>30</age>
  17.         <sex>F</sex>
  18.     </SetFields>
  19.     <FreeXML>
  20.     <Custom1>
  21.         <CustomString>aaaaaa</CustomString>
  22.         <CustomInt>12345</CustomInt>
  23.     </Custom1>
  24.     </FreeXML>
  25. </OverallDocument>
  26.        
  27. <Custom1>
  28.     <CustomString>aaaaaa</CustomString>
  29.     <CustomInt>12345</CustomInt>
  30. </Custom1>
  31.        
  32. <OverallDocument>
  33.     <SetFields>
  34.         <name>Jane Doe</name>
  35.         <age>30</age>
  36.         <sex>F</sex>
  37.     </SetFields>
  38.     <FreeXML>
  39.     <hl:Custom1>
  40.         <CustomString>aaaaaa</CustomString>
  41.         <CustomInt>12345</CustomInt>
  42.     </hl:Custom1>
  43.     </FreeXML>
  44. </OverallDocument>
  45.        
  46. dim xdoc as xmldocument = xmldocument
  47. 'add namespace and prefix
  48. xdoc.loadxml(xmlcode)
  49.        
  50. Dim xstring As String = xmldata
  51. Dim sreader As New System.IO.StringReader(xstring) 'load string into stringreader
  52. Dim xreader As New XmlTextReader(sreader)          'load stringreader into xmltextreader
  53. xreader.Namespaces = False                         'turn off namespaces
  54. Dim xdoc As XmlDocument = New XmlDocument          'create xmldocument
  55. xdoc.Load(xreader)                                 'Load xmltextreader into xmldocument