CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008
    Posts
    1

    Read HTML Tags in XML Node

    Hi all,

    I have an XML as following. I'm trying to read it with the following code:

    DataSet cars = new DataSet();
    cars.ReadXml("http://localhost/cars/newcars.xml");

    All the nodes are getting properly populated into the Dataset created EXCEPT the "description" node. I can't find a way to make ReadXML (or similar method) to get the content of the description node and skip the HTML tags. I would like just treat that portion as pure text, ignoring the html content.

    My question would be: How can I read an XML file which some of the nodes have HTML tags inserted? How could I avoid that the program treats the HTML tags as XML nodes>

    thanks,

    Juan

    <cars>
    <car>
    <color>red</color>
    <model>ford</model>
    <description>
    <p xmlns="http://www.w3.org/1999/xhtml"><span class="textnorm" title="">Super</br>fast</br></span></p><h2 xmlns="http://www.w3.org/1999/xhtml"><span class="textnorm" title="">Reasons to buy</span></h2><p xmlns="http://www.w3.org/1999/xhtml">Just because</p>
    </description>
    </car>
    </cars>

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Read HTML Tags in XML Node

    You could try use the CDATA tag. Then you only need to change the xmlfile and not your code

    Code:
    <cars>
     <car>
      <color>red</color>
      <model>ford</model>
      <description>
       <![CDATA[ 
        <p xmlns="http://www.w3.org/1999/xhtml"><span class="textnorm" title="">Super</br>fast</br></span></p><h2 xmlns="http://www.w3.org/1999/xhtml"><span class="textnorm" title="">Reasons to buy</span></h2><p xmlns="http://www.w3.org/1999/xhtml">Just because</p>
        ]]><!--end CDATA tag-->
      </description>
     </car>
    </cars>

Tags for this Thread

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

Featured