Getting a certain node using DataSet

Posted by MarceloRamires on Stack Overflow See other posts from Stack Overflow or by MarceloRamires
Published on 2010-03-29T12:48:05Z Indexed on 2010/03/29 13:03 UTC
Read the original article Hit count: 265

Filed under:
|
|
|
|

I have the following XML

<xml>
   <ObsCont xCampo="field1">
      <xTexto>example1</xTexto>
   </ObsCont>
   <ObsCont xCampo="field2">
      <xTexto>example2</xTexto>
   </ObsCont>
   <ObsCont xCampo="field3">
      <xTexto>example3</xTexto>
   </ObsCont>
<field>information</field>
</xml>

Is there a way to get the content of "xTexto" inside the ObsCont that has "field2" value for the attribute xCampo using DataSet ?

It would be desireable to have a single liner like the following:

DataSet ds = new DataSet();
ds.ReadXml(StrArquivoProc);
ds.Tables["xml"].Rows[0]["field"].ToString();
//field == "information"

If I use the same method I'm not specifying that I want the one with the desired attribute.

© Stack Overflow or respective owner

Related posts about dataset

Related posts about Xml