Urgent! Loop through first node with position()

Urgent! Loop through first node with position()

Post by qluo » Fri, 04 Jul 2003 23:02:07



My data structure (under the same <DISTRIBUTIONS>, there are the same
number of <SCHEDULE> with the same name):

<DISTRIBUTIONS>
     <DISTRIBUTION>D1
         <SCHEDULE>A</SCHEDULE>
     </DISTRIBUTION>
     <DISTRIBUTION>D2
         <SCHEDULE>A</SCHEDULE>
     </DISTRIBUTION>
</DISTRIBUTIONS>
<DISTRIBUTIONS>
     <DISTRIBUTION>D5
         <SCHEDULE>C</SCHEDULE>
        <SCHEDULE>D</SCHEDULE>
     </DISTRIBUTION>
     <DISTRIBUTION>D6
         <SCHEDULE>C</SCHEDULE>
        <SCHEDULE>D</SCHEDULE>
     </DISTRIBUTION>
</DISTRIBUTIONS>

My desired action result:

   For each <DISTRIBUTIONS>, get all <SCHEDULE> for the first
<DISTRIBUTION>.

When I use the following loop, the problem is, I may get SCHEDULE A, C &
D for DISTRIBUTION  D1, but I only need SCHEDULE A for DISTRIBUTION  D1.

<xsl:for-each select="//DISTRIBUTIONS/DISTRIBUTION[position()=1]/SCHEDULE">

How do I get my desired result.

 
 
 

Urgent! Loop through first node with position()

Post by Oleg Tkachenk » Sat, 05 Jul 2003 00:20:26



> My data structure (under the same <DISTRIBUTIONS>, there are the same
> number of <SCHEDULE> with the same name):

> <DISTRIBUTIONS>
>     <DISTRIBUTION>D1
>         <SCHEDULE>A</SCHEDULE>
>     </DISTRIBUTION>
>     <DISTRIBUTION>D2
>         <SCHEDULE>A</SCHEDULE>
>     </DISTRIBUTION>
> </DISTRIBUTIONS>
> <DISTRIBUTIONS>
>     <DISTRIBUTION>D5
>         <SCHEDULE>C</SCHEDULE>
>     <SCHEDULE>D</SCHEDULE>
>     </DISTRIBUTION>
>     <DISTRIBUTION>D6
>         <SCHEDULE>C</SCHEDULE>
>     <SCHEDULE>D</SCHEDULE>
>     </DISTRIBUTION>
> </DISTRIBUTIONS>

> My desired action result:

>   For each <DISTRIBUTIONS>, get all <SCHEDULE> for the first
> <DISTRIBUTION>.

> When I use the following loop, the problem is, I may get SCHEDULE A, C &
> D for DISTRIBUTION  D1, but I only need SCHEDULE A for DISTRIBUTION  D1.

> <xsl:for-each select="//DISTRIBUTIONS/DISTRIBUTION[position()=1]/SCHEDULE">

> How do I get my desired result.

(//DISTRIBUTIONS/DISTRIBUTION)[1]/SCHEDULE

Read "Things to Know and Avoid When Querying XML Documents with XPath" by Dare
at http://msdn.microsoft.com/library/en-us/dnexxml/html/xml06172002.asp
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

 
 
 

Urgent! Loop through first node with position()

Post by qluo » Fri, 04 Jul 2003 23:26:53


That works. Thank you.


>> My data structure (under the same <DISTRIBUTIONS>, there are the same
>> number of <SCHEDULE> with the same name):

>> <DISTRIBUTIONS>
>>     <DISTRIBUTION>D1
>>         <SCHEDULE>A</SCHEDULE>
>>     </DISTRIBUTION>
>>     <DISTRIBUTION>D2
>>         <SCHEDULE>A</SCHEDULE>
>>     </DISTRIBUTION>
>> </DISTRIBUTIONS>
>> <DISTRIBUTIONS>
>>     <DISTRIBUTION>D5
>>         <SCHEDULE>C</SCHEDULE>
>>     <SCHEDULE>D</SCHEDULE>
>>     </DISTRIBUTION>
>>     <DISTRIBUTION>D6
>>         <SCHEDULE>C</SCHEDULE>
>>     <SCHEDULE>D</SCHEDULE>
>>     </DISTRIBUTION>
>> </DISTRIBUTIONS>

>> My desired action result:

>>   For each <DISTRIBUTIONS>, get all <SCHEDULE> for the first
>> <DISTRIBUTION>.

>> When I use the following loop, the problem is, I may get SCHEDULE A, C
>> & D for DISTRIBUTION  D1, but I only need SCHEDULE A for DISTRIBUTION  
>> D1.

>> <xsl:for-each
>> select="//DISTRIBUTIONS/DISTRIBUTION[position()=1]/SCHEDULE">

>> How do I get my desired result.

> (//DISTRIBUTIONS/DISTRIBUTION)[1]/SCHEDULE

> Read "Things to Know and Avoid When Querying XML Documents with XPath"
> by Dare at
> http://msdn.microsoft.com/library/en-us/dnexxml/html/xml06172002.asp

 
 
 

1. Loop thru XML with VB - cannot get Node Name

Hi

I pass in the root node to this fct. I can get all the node values
but I get #Text when I print out the nodeName.

Is there some other way to get the node name???

Thanks
Steve

Sub Traverse_XML(n As IXMLDOMNode)
    Dim nn As IXMLDOMNode

    'stick this node into the tv
    'do stuff with attributes, if relevant

    If n.hasChildNodes Then
        For Each nn In n.childNodes
            Traverse_Xml nn
        Next nn
    Else

        Debug.Print n.nodeName

        Debug.Print n.nodeValue
    End If

End Sub

2. Clickable Nodes

3. Judge the first one node or the last one node in XSL defination

4. SP2SRP1 using Domain GPO

5. Select a node by position that equals position of another node?

6. image rollover with sound

7. HOWTO : first sort by, and then re-orient position of node and its ancestors in output

8. Describe Macro Help

9. xsl not looping thru all the children

10. Looping thru DOMDocument attributes

11. Looping thru xml using msxml

12. looping thru attributes

13. Looping thru N elements!!