Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: read xml-data with the TXML Document Component of the C++Builder


This question is answered.


Permlink Replies: 3 - Last Post: Dec 12, 2016 12:35 PM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Ivo Feizelmeier

Posts: 2
Registered: 1/9/17
read xml-data with the TXML Document Component of the C++Builder  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 5:14 AM
Hi,

the following code is an example of correct xml-code. I can open it with a parser that I downloaded from the internet (it is called "foxe"). This parser shows the xml-data absolut correct.

But when I try to read the data with the TXML Document Component, the result is not correct. For example the elements called "SubKomp2" and "SubKomp1" do not appear in the list of the parsed document.

I also have not understood how the the list with the parsed document works. The foxe parser for example shows the structure of the data exaxctly how they are organized in the source data. The TXML Document seems to show the structure according to another logic that I do not understand. I searched in the internet but I did not find information about how the TXML Document shows the parsed data. Are there links in the internet that do describe the list of the parsed document ?

Here is the xml-data:

<?xml version="1.0" encoding="UTF-8"?>
<Stamm>
<Zweig1>
<Komp1>FJ-7264</Komp1>
<Komp2>Symphony-Bantu</Komp2>
<Komp3>Vincent Nguini</Komp3>
<Komp4>1994</Komp4>
<Komp5>Mesa Records</Komp5>
</Zweig1>
<Zweig1>
<Komp1>DG-3636</Komp1>
<Komp2>ANightat</Komp2>
<Komp3>Queen
<SubKomp2>Text</SubKomp2>
</Komp3>
<Komp4>1992</Komp4>
<Komp5>Philips Records</Komp5>
<Komp6>Sonstiges</Komp6>
</Zweig1>
<Zweig1>
<Komp1>FS-7361</Komp1>
<Komp2>StreicherQuintett</Komp2>
<Komp3>AnneSophiMutter
<SubKomp1>Haus</SubKomp1>
</Komp3>
<Komp4>1992</Komp4>
<Komp5>Grammophon</Komp5>
</Zweig1>
</Stamm>

Edited by: Ivo Feizelmeier on Dec 9, 2016 5:41 AM

I use C++ Builder 2007
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: read xml-data with the TXML Document Component of the C++Builder [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 9, 2016 12:02 PM   in response to: Ivo Feizelmeier in response to: Ivo Feizelmeier
Ivo wrote:

But when I try to read the data with the TXML Document Component,
the result is not correct. For example the elements called "SubKomp2"
and "SubKomp1" do not appear in the list of the parsed document.

I highly doubt that. Please show your TXMLDocument code, you are likely
just not using it correctly. You have to take into account that SubKomp1
and SubKomp2 are child nodes of Komp3, they are NOT children of Zweig1 like
the other values are.

The foxe parser for example shows the structure of the data exaxctly
how they are organized in the source data.

I tried Foxe with your XML example and it is actually missing some data in
its display. Looks like Foxe is either not parsing the XML correctly, or
is simply not displaying everything it parses. If you look closer, you will
see that the second Komp3 tree node is missing the "Queen" text, and the
third Komp3 tree node is missing the "AnneSophiMutter" text. These Komp3
elements have two child nodes - a text node, and a SubKomp(1|2) element.
Foxe is only displaying the latter. But TXMLDocument allows you to access
both children.

The TXML Document seems to show the structure according to another
logic that I do not understand.

TXMLDocument is presenting the XML exactly as it is really structured. I
suggest you read the XML spec to understand the structure:

http://www.w3.org/TR/xml/

--
Remy Lebeau (TeamB)
Ivo Feizelmeier

Posts: 2
Registered: 1/9/17
Re: read xml-data with the TXML Document Component of the C++Builder [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 12, 2016 5:42 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Hi Remy,

thanks for your answer. Concerning the foxe issue: The Queen and Anne Sophie Mutter text misses, I also tried it again and you are right.

I also think that the parser works correctly concerning the end result.

With the command "ShowMessage(Stamm->XML)" in my C++ application the correct data appears, so the parsing was correct.

The only thing I have not understood is the display of the data binding wizard. Please have a look at the two examples:

The first example shows the components of the xml data that belong to my post above. Then I have a new xml source code that brings the results listed below. I do not understand why in the one example the SubKomp items are listed and in the other example there are no SubKomp┬┤s and Komp3 does not have different types.

Here is the data:

Komplexe Typen
- <> StammType
- + Zweig1
=Komp1
=Komp2
=Komp3
=Komp4
=Komp5
=Komp6
-<>Zweig1 Type
=Komp1
=Komp2
= Komp3
=Komp4
= Komp5
= Komp6
===Einfache Typen
abc string
abc integer

Then the new source code with the results:

<?xml version="1.0" encoding="UTF-8"?>
<Stamm>
<Zweig1>
<Komp1>FJ-7264</Komp1>
<Komp2>Symphony-Bantu</Komp2>
<Komp3>Vincent Nguini
<SubKomp1>Test</SubKomp1>
</Komp3>
<Komp4>1994</Komp4>
<Komp5>Mesa Records</Komp5>
</Zweig1>
<Zweig1>
<Komp1>DG-3636</Komp1>
<Komp2>ANightat</Komp2>
<Komp3>Queen</Komp3>
<Komp4>1992</Komp4>
<Komp5>Philips Records</Komp5>
<Komp6>Sonstiges</Komp6>
</Zweig1>
<Zweig1>
<Komp1>FS-7361</Komp1>
<Komp2>StreicherQuintett</Komp2>
<Komp3>AnneSophiMutter
<SubKomp1>Haus</SubKomp1>
</Komp3>
<Komp4>1992</Komp4>
<Komp5>Grammophon</Komp5>
</Zweig1>
</Stamm>

Komplexe Typen
-<> StammType
-+++Zweig1
=Komp1
=Komp2
-<>Komp3
-SubKomp1
=Komp3
=Komp4
=Komp5
=Komp6
-<>Zweig1Type
=Komp1
=Komp2
-<>Komp3
=SubKomp1
=Komp3
=Komp4
=Komp5
=Komp6
-<>Komp3Type
=SubKomp1
<>Komp3Type2
===EinfacheTypen

Unfortunately I have no possibility to show a screenshot,but you can copy the data in your databinding wizard to see the result that I have written here with the "<,>,=,+,-" - signs.

KindRegards

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: read xml-data with the TXML Document Component of the C++Builder[Edit]
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 12, 2016 12:35 PM   in response to: Ivo Feizelmeier in response to: Ivo Feizelmeier
Ivo wrote:

The only thing I have not understood is the display of the data
binding wizard.

My previous reply was based on the assumption that you were using TXMLDocument
by itself, not the Data Binding wizard (you did not say that earlier). I
don't trust the Data Binding wizard, it doesn't support everything, and can/does
get some things wrong. I don't know if/how it handles the kind of element-inside-of-text
nesting that your XML is using. You might be better off just using TXMLDocument
as-is and not the Data Binding wizard at all.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02