Click here to Skip to main content
15,885,767 members
Articles / Desktop Programming / Windows Forms

XML String Browser (just like Internet Explorer) using the WebBrowser Control

Rate me:
Please Sign up or sign in to vote.
4.48/5 (15 votes)
14 Apr 2008CPOL6 min read 124.5K   3.2K   40  
This article will show you how to view a colourful collapsible treeview for XML Strings/XmlDocument in a browser (just like Internet Explorer) without the need for XML files.
��<Sample xmlns="http://tempuri.org/Sample2.xsd" abc="456" xml:a="123" xmlns:b="http://tempuri.org/Sample4.xsd">

  <Employee>

    <EmployeeID MyAttribute="1" xmlns="123"><![CDATA[132]]></EmployeeID>

    <FirstName TestAtt="134">Smith</FirstName>

    <LastName>John</LastName>

    <Employee_Id>1</Employee_Id>

  </Employee>

  <Address>

    <PostalCode>90210</PostalCode>

    <State>California</State>

    <Country>USA</Country>

    <Address_Id>5</Address_Id>

    <Organisation_Id>1</Organisation_Id>

  </Address>

  <Address>

    <PostalCode>92301</PostalCode>

    <State>California</State>

    <Country>USA</Country>

    <Address_Id>1</Address_Id>

    <Employee_Id>1</Employee_Id>

  </Address>

  <Street>

    <Number>234</Number>

    <Name>John Street</Name>

    <Address_Id>1</Address_Id>

  </Street>

  <Role>

    <RoleID>1</RoleID>

    <Description>This position is a managerial position</Description>

    <Name>Manager</Name>

    <Employee_Id>1</Employee_Id>

  </Role>

  <Organisation>

    <Organisation_Id>1</Organisation_Id>

    <Name>ABC Corporation</Name>

    <OrganisationID>1</OrganisationID>

    <Employee_Id>1</Employee_Id>

  </Organisation>

  <Role>

    <RoleID>1</RoleID>

    <Employee_Id>2</Employee_Id>

    <Name>Manager</Name>

    <Description>This position is a managerial position</Description>

  </Role>

  <Role>

    <RoleID>2</RoleID>

    <Employee_Id>3</Employee_Id>

    <Name>Employee</Name>

    <Description>This position is an employee position</Description>

  </Role>

  <Role>

    <RoleID>2</RoleID>

    <Employee_Id>4</Employee_Id>

    <Name>Employee</Name>

    <Description>This position is an employee position</Description>

  </Role>

  <Street>

    <Address_Id>2</Address_Id>

    <Name>George Street</Name>

    <Number>19</Number>

  </Street>

  <Street>

    <Address_Id>3</Address_Id>

    <Name>Davis Drive</Name>

    <Number>8</Number>

  </Street>

  <Street>

    <Address_Id>4</Address_Id>

    <Name>Oxford Street</Name>

    <Number>7</Number>

  </Street>

  <Street>

    <Address_Id>5</Address_Id>

    <Name>Hollywood Boulevard</Name>

    <Number>4</Number>

  </Street>

  <Street>

    <Address_Id>6</Address_Id>

    <Name>Melrose Place</Name>

    <Number>3</Number>

  </Street>

  <Employee>

    <FirstName>Johnson</FirstName>

    <LastName>Stuart</LastName>

    <Employee_Id>2</Employee_Id>

    <EmployeeID>2</EmployeeID>

  </Employee>

  <Employee>

    <FirstName>OBrien</FirstName>

    <LastName>Tom</LastName>

    <Employee_Id>3</Employee_Id>

    <EmployeeID>3</EmployeeID>

  </Employee>

  <Employee>

    <FirstName>Sullivan</FirstName>

    <LastName>David</LastName>

    <Employee_Id>4</Employee_Id>

    <EmployeeID>4</EmployeeID>

  </Employee>

  <Organisation>

    <Organisation_Id>2</Organisation_Id>

    <OrganisationID>2</OrganisationID>

    <Employee_Id>2</Employee_Id>

    <Name>Sample Corporation</Name>

  </Organisation>

  <Organisation>

    <Organisation_Id>3</Organisation_Id>

    <OrganisationID>3</OrganisationID>

    <Employee_Id>3</Employee_Id>

    <Name>Jones Corporation</Name>

  </Organisation>

  <Organisation>

    <Organisation_Id>3</Organisation_Id>

    <OrganisationID>3</OrganisationID>

    <Employee_Id>4</Employee_Id>

    <Name>Jones Corporation</Name>

  </Organisation>

  <Address>

    <Address_Id>2</Address_Id>

    <Employee_Id>2</Employee_Id>

    <PostalCode>M5A2T4</PostalCode>

    <State>Manitoba</State>

    <Country>Canada</Country>

  </Address>

  <Address>

    <Address_Id>3</Address_Id>

    <Employee_Id>3</Employee_Id>

    <PostalCode>9999</PostalCode>

    <State>Victoria</State>

    <Country>Australia</Country>

  </Address>

  <Address>

    <Address_Id>4</Address_Id>

    <Employee_Id>4</Employee_Id>

    <PostalCode>1350</PostalCode>

    <State>Western Australia</State>

    <Country>Australia</Country>

  </Address>

  <Address>

    <Address_Id>6</Address_Id>

    <Organisation_Id>2</Organisation_Id>

    <PostalCode>95320</PostalCode>

    <State>California</State>

    <Country>USA</Country>

  </Address>

</Sample>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Australia Australia
George Zabanah has been architecting and developing solutions commercially from start to finish for over 11 years. He has been programming since he was 11 (for over 25 years now!) using many different technologies (almost all Microsoft). George is proficient in many languages and employs best practices wherever possible using design patterns, .NET, XSLT, XML, Regular Expressions, various flavours of SQL (to name just a few). His favourite tools, however, are the whiteboard and Sparx Enterprise Architect/Powerpoint. Many waking moments have been spent by George thinking about solutions in his head (even while watching tv). His best moments are the "Eureka" moments when he wakes up from a good sleep (or after watching tv) to find that his latest challenge has been solved!

Comments and Discussions