Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Handling specific XML structure
Message
 
À
19/03/2007 22:22:29
Information générale
Forum:
ASP.NET
Catégorie:
XML
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01205926
Message ID:
01205968
Vues:
13
Not that there's anything wrong with your code but you might want to look into the XPathNavigator for writing and parsing XML Documents. It's much easier in many ways and often does away with complex string expressions for finding content and parsing over it.

+++ Rick ---


>
>
><?xml version="1.0" ?>
><Logs xmlns="http://www.mywebsite.com/schemas/compliance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="2.0">
>   <Log>
>      <Exceptions>
>         <Exception>
>            <GroupName>Labor Time</GroupName>
>         </Exception>
>         <Exception>
>            <GroupName>Parts Usage</GroupName>
>         </Exception>
>      </Exceptions>
>   </Log>
>   <Log>
>      <Exceptions>
>         <Exception>
>            <GroupName>Labor Time 2</GroupName>
>         </Exception>
>         <Exception>
>            <GroupName>Parts Usage 2</GroupName>
>         </Exception>
>      </Exceptions>
>   </Log>
></Logs>
>
>
>I used this code to get the node list from my XML class:
>
>
>loXml.GetXMLNodeList("//ns:Logs/ns:Log/ns:Exceptions/ns:Exception")
>
>
>Then, I can scan it like this:
>
>
>        For Each loNodeRecord In loXml.oXmlNodeList
>            lnCounter = lnCounter + 1
>            loStringBuilder.Append("<TR>")
>            loStringBuilder.Append("<TD ALIGN=RIGHT>" + lnCounter.ToString + ".")
>            For Each loNodeField In loNodeRecord.ChildNodes
>                Select Case loNodeField.Name
>                    Case "GroupName"
>                        loStringBuilder.Append("<TD>" + Trim(loNodeField.InnerText))
>                End Select
>            Next
>        Next
>
>
>However, doing it like this means that I will end up with four records because I have those branches that match in the first hierarchy and another two in the second hierarchy. The client wants that I only get the records from the first one. How can I adjust to only get the records from the first one? Is there a way to identify an identifier of 1 in the loXml.GetXMLNodeList() command to let the class know that I want the first occurence only? I think I saw something like that before where we can specify and identifier for such a need.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform