Question How to display text inside the qoutation ("") in a richtextbox.

ecenon

New member
Joined
Mar 30, 2020
Messages
2
Programming Experience
Beginner
Hi,

I am currently creating an automation system that can read, edit and save XML file using VB.net(VS2010). Is it possible to to display all the text in a richtextbox inside the qoutation mark("") under the field name? Sample illustatration below:

XML file:
<?xml version="1.0" encoding="UTF-8"?>
<names>
<name = "John Doe">
<title>Associate</title>
<supervisor>Giada De Laurentiis</supervisor>
</name>
<name = "Jane Doe">
<title>Associate</title>
<supervisor>Giada De Laurentiis</supervisor>
</name>
</names>

Output (Richtextbox):
John Doe
Jane Doe

Thanks in Advance :)
 
Firstly, the question you are actually asking here is how to extract data from an XML file, so that is what you should be researching online. There's loads of information on that so you should be able to find something useful and at least make an attempt.

Secondly, that's not even valid XML. You can't assign something to the element name. You need to either have an attribute:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<names>
  <name value="John Doe">
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
  <name value="Jane Doe">
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
</names>
or another child element:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<names>
  <name>
    <value>John Doe</value>
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
  <name>
    <value>Jane Doe</value>
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
</names>
How you extract the values you are interested in depends on whether it is the content of an element or an attribute.
 
Firstly, the question you are actually asking here is how to extract data from an XML file, so that is what you should be researching online. There's loads of information on that so you should be able to find something useful and at least make an attempt.

Secondly, that's not even valid XML. You can't assign something to the element name. You need to either have an attribute:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<names>
  <name value="John Doe">
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
  <name value="Jane Doe">
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
</names>
or another child element:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<names>
  <name>
    <value>John Doe</value>
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
  <name>
    <value>Jane Doe</value>
    <title>Associate</title>
    <supervisor>Giada De Laurentiis</supervisor>
  </name>
</names>
How you extract the values you are interested in depends on whether it is the content of an element or an attribute.


Hi, thanks for the clarification and my apologies as well for the confusion.

But my question is is it possible to diplay John Doe from <name value="John Doe"> in a textbox? I already did extract and diplay the xml file in a richtextbox.
 
Of course it is. What don't you understand about the information you found about read XML files when you searched online? If you explain what you've done and where you're stuck, we can help with that. If you haven't done anything then you haven't got stuck yet. In short, do what you can for yourself first, rather than just assuming that it's too hard and asking others to just write your code for you. If you try and fail, there are plenty of people keen to help. If you're not going to try, people will tend to be a little less enthusiastic. Here's a start:

 
Back
Top