Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21278

Access value of a specific Node

$
0
0
Hi there,

I ve got a question.

I need to search a XML Document for certain nodes and I m using the following Code(its just a part of the whole code):

Code:

For Each NodeLN In NodeListLN


                                NodeLNType = NodeLN.getAttribute("lnClass")
                                'NodeCountPTOC = NodeLN.


                                If NodeLNType = "PTOC" Then


                                        Dim PTOC As PTOC

                                        Set NodeListDOI = NodeLN.childNodes

                                        PTOC.Modulname = "PTOC"

                                        For Each NodeDOI In NodeListDOI

                                                NodeDoiName = NodeDOI.getAttribute("name")


                                                If NodeDoiName = "StrVal" Then

                                                        Set NodeListSDI = NodeDOI.childNodes

                                                        For Each NodeSDI In NodeListSDI

                                                                If NodeSDI.getAttribute("name") ="setMag" Then

                                                                PTOC.Threshold = NodeSDI.lastChild.Text


                                                                End If

                                                        Next





                                                ElseIf NodeDoiName = "OpDLTmms" Then

                                                        Set SDI = NodeDOI.childNodes


                                                '        PTOC.Delay =

                                                ElseIf NodeDoiName = "DrpoutRat" Then

                                                        Set SDI = NodeDOI.childNodes

                                                '        PTOC.FallbackRatio =

                                                End If
                                               

                                        Next

PTOC is a UDT i defined.
I m especially interested in the highlightet part because i Know the Name of the Childnode (NodeSDI) already (Its "setmag").
I think its not the best way to build another Nodelist of all the NodeSDI Nodes.

here is a part of the xml i use:

Code:

              <LN>
                  <Private type>33ab0908-292e-424b-9a7b-73a09aad1b6c</Private>
                  <DOI name="Mod" desc="Modus (steuerbar)"/>
                  <DOI name="Beh" desc="Zustand"/>
                  <DOI name="Health" desc="Bereitschaft"/>
                  <DOI name="NamPlt" desc="Bezeichnung">
                    <DAI name="configRev">
                        <Val>634963452378353030</Val>
                    </DAI>
                  </DOI>
                  <DOI name="Str" desc="Anregung"/>
                  <DOI name="Op" desc="Auslösemeldung"/>
                  <DOI name="StrVal" desc="Schwellwert">
                    <SDI name="setMag">
                        <DAI name="f">
                          <Val>1500</Val>
                        </DAI>
                    </SDI>
                    <SDI name="units">
                        <DAI name="SIUnit">
                          <Val>A</Val>
                        </DAI>
                        <DAI name="multiplier">
                          <Val></Val>
                        </DAI>
                    </SDI>
                    <SDI name="minVal">
                        <DAI name="f">
                          <Val>30.0000019</Val>
                        </DAI>
                    </SDI>
                    <SDI name="maxVal">
                        <DAI name="f">
                          <Val>100000</Val>
                        </DAI>
                    </SDI>
                    <SDI name="stepSize">
                        <DAI name="f">
                          <Val>0</Val>
                        </DAI>
                    </SDI>
                  </DOI>

My questions are:

1.Is there another possibility to get the value out of <DOI name="StrVal" desc="Schwellwert"><SDI name="setMag"><DAI name="f"> <Val>1500</Val>
(I need to get the 1500 as value)

2.Can someone tell me why NodeSDI.lastchild.Text isnt working? I get a mismatch error. (This one I solved myself...took just one moment of thinking... text as it says itself while return a string..:D...PTOC.threshhold is desclared as double...stupid mistake)

3. Is it possible to use Xpath from an already discovered Node?

Thanks for your help. :-)

Sascha

Viewing all articles
Browse latest Browse all 21278

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>