Forum Discussion

kenhepworth's avatar
kenhepworth
Occasional Contributor
13 years ago

NewDataSet XML files

Hi,



I am currently attempting to try and retrieve the data from a NewDataSet XML file, and I am having problems getting the results I want. Whenever I want to get the record and the nodename, I always get #text for the nodename. A sample of the XML file, the code that I am using and the result I am getting are below. I want the result that I am getting for the value to look like "Cfgtype : ADMEM", but I keep on getting this #text



I haven't had any problems with other types of XML files, it is just this NewDataSet one is giving me strife.



Any suggestiones would be great.



Regards,

Ken



<NewDataSet>

  <PESConfig>

    <Cfgtype>ADMEM</Cfgtype>

    <Cfgakey1 />

    <Cfgakey2 />

    <Cfgikey1>0</Cfgikey1>

    <Cfgikey2>0</Cfgikey2>

    <Cfgstr1 />

    <Cfgstr2 />

    <Cfgint1>0</Cfgint1>

    <Cfgint2>0</Cfgint2>

    <Cfgfloat1>0</Cfgfloat1>

    <Cfgfloat2>0</Cfgfloat2>

  </PESConfig>

  <PESConfig>

    <Cfgtype>AGR</Cfgtype>

    <Cfgakey1 />

    <Cfgakey2 />

    <Cfgikey1>0</Cfgikey1>

    <Cfgikey2>0</Cfgikey2>

    <Cfgstr1 />

    <Cfgstr2 />

    <Cfgint1>0</Cfgint1>

    <Cfgint2>0</Cfgint2>

    <Cfgfloat1>0</Cfgfloat1>

    <Cfgfloat2>0</Cfgfloat2>

  </PESConfig>

  <PESConfig>

    <Cfgtype>ALZLU</Cfgtype>

    <Cfgakey1 />

    <Cfgakey2 />

    <Cfgikey1>0</Cfgikey1>

    <Cfgikey2>0</Cfgikey2>

    <Cfgdate1>2002-06-20T17:39:06+10:00</Cfgdate1>

  </PESConfig>

</NewDataSet>



The code that I am attempting to use is



FID = Log.CreateFolder(ANode.nodeName)


' If the node value is not null, output it


If aqObject.GetVarType(ANode.nodeValue) <> 1 Then


Log.Message ANode.nodename + " : " + ANode.nodeValue


 


End If



And it gives me a result like this

NewDataSet

PESConfig   

Cfgtype   

#text 

#text : ADMEM   

Cfgakey1 

Cfgakey2   

Cfgikey1   

#text l  

#text : 0   

Cfgikey2   

#text   

#text : 0   

Cfgstr1   

Cfgstr2   

Cfgint1   

#text   

#text : 0   

Cfgint2   

#text   

#text : 0   

Cfgfloat1   

#text   

#text : 0   

Cfgfloat2   

1 Reply


  • Hi Ken,





    Text snippets are XML nodes too, according to XML rules, so it is expected that you get such node names for the text nodes. However, different XML parsers may handle such nodes differently. If you need to get text located within an XML node, you should probably use another parser or another property (like innerXml or innerText), because the XML parser you currently use seems not to treat the text located within a node as node value (even though some parsers, at least the XmlDocument object in .NET do this the way you need, as far as I remember).