Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3791

Parsing an xml Document

$
0
0

Hi people.
I’ve been messing about for a good while now and being blocked by something that must be really elementary, but that I"m not seeing :frowning:. I’m trying to parse an xml file structured as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<TheRoot>
  <MessageHeader>
    <MessageId>20240602012345</MessageId>
    <MessageSender>
      <PartyID>1234</PartyID>
      <PartyName>My Company Name</PartyName>
    </MessageSender>
    <MessageRecipient>Recepient Name</MessageRecipient>
  </MessageHeader>
  <MessageDates>
    <StartDate>2024-06-02</StartDate>
    <EndDate>2024-06-02</EndDate>
  </MessageDates>
  <Entry1>
    <UserId>01234567890123</UserId>
    <EntryId>
      <Eno>ABC0123456</Eno>
    </EntryId>
    <Title>This is the Title</Title>
  </Entry1>
  <Comment>Some sort of comment</Comment>
  <NumberOfEntries>1</NumberOfEntries>
</TheRoot>

There’s only 1 “Entry” (Entry1) in my example, but in practice there could be dozens! I will be using loops and all to deal with those, but my problem is to access a given value, for instance, If I want to read Entry1/Eno, I would hope to get “ABC0123456”.
I do something like:

Var nodeIwant As XmlNode = xml.DocumentElement.Child(2).Child(1).Child(0)
Var txt As Variant = nodeIwant.Value
MessageBox nodeIwant.ToString

I get ABC0123456 with the tags, not just the text.
What am I doing wrong ? I’ve messes about with all sorts of combinations, but I’m not getting it.
Can someone there help me please ? Thanks in advance.

8 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 3791

Trending Articles