Connecting Tech Pros Worldwide Forums | Help | Site Map

Help: Pre-poulating a web form with xml data

captain_gni@yahoo.com
Guest
 
Posts: n/a
#1: Oct 19 '06
Hi All, New to asp.net here. Been combing google since monday trying to
find the right solution. Most of the solutions are good and reflect the
same examples in the .net books I have but xml is sketchy to me and
this isn't you typical real world project.

Here's the scenario. I query an api via a URL and it responds with xml
data which I need to use to prepoulate the fields of a web form. I
haven't been able to get my head around this one. As you can see from
the XML example below, all of the elements I am after (name, address,
phone etc) have the same element name "attr". I have no control over
the xml document so I can't arrange the tags in a more useful manner.
If you look at the xml, I need to assign each value to a corresponding
textfield on a web form. So the value of attr name="mail" which is
jdoe@msn.com must be assign to txtMail.text. So far I have been able to
return all of the values but I have not been successful in linking them
to that childnode (if thats correct) of name, mail, address etc.

Also should mention I can't really use an array solution like attr[1],
attr[2] which will work, but as I said I have no control over the xml
doc and if the positions change my app is hosed.

My deadline is tomorrow so thank you sincerely for any and ALL
suggestions.

BK

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE dsml (View Source for full doctype...)>
- <dnt complete="true">
- <directory-entries>
- <entry id="A0236721002">
- <attr name="name">
<value>John Doe</value>
</attr>
- <attr name="mail">
<value>jdoe@msn.com</value>
</attr>
- <attr name="address">
<value>123 Some Street</value>
</attr>
- <attr name="city">
<value>New York</value>
</attr>
- <attr name="state">
<value>NY</value>
</attr>
- <attr name="zip">
<value>10019</value>
</attr>
- <attr name="phone">
<value>(212)555-1212</value>
</attr>
</entry>
</directory-entries>
</dnt>


Jester98x
Guest
 
Posts: n/a
#2: Oct 23 '06

re: Help: Pre-poulating a web form with xml data



captain_gni@yahoo.com wrote:
Quote:
Hi All, New to asp.net here. Been combing google since monday trying to
find the right solution. Most of the solutions are good and reflect the
same examples in the .net books I have but xml is sketchy to me and
this isn't you typical real world project.
>
Here's the scenario. I query an api via a URL and it responds with xml
data which I need to use to prepoulate the fields of a web form. I
haven't been able to get my head around this one. As you can see from
the XML example below, all of the elements I am after (name, address,
phone etc) have the same element name "attr". I have no control over
the xml document so I can't arrange the tags in a more useful manner.
If you look at the xml, I need to assign each value to a corresponding
textfield on a web form. So the value of attr name="mail" which is
jdoe@msn.com must be assign to txtMail.text. So far I have been able to
return all of the values but I have not been successful in linking them
to that childnode (if thats correct) of name, mail, address etc.
>
Also should mention I can't really use an array solution like attr[1],
attr[2] which will work, but as I said I have no control over the xml
doc and if the positions change my app is hosed.
>
My deadline is tomorrow so thank you sincerely for any and ALL
suggestions.
>
BK
>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE dsml (View Source for full doctype...)>
- <dnt complete="true">
- <directory-entries>
- <entry id="A0236721002">
- <attr name="name">
<value>John Doe</value>
</attr>
- <attr name="mail">
<value>jdoe@msn.com</value>
</attr>
- <attr name="address">
<value>123 Some Street</value>
</attr>
- <attr name="city">
<value>New York</value>
</attr>
- <attr name="state">
<value>NY</value>
</attr>
- <attr name="zip">
<value>10019</value>
</attr>
- <attr name="phone">
<value>(212)555-1212</value>
</attr>
</entry>
</directory-entries>
</dnt>
BK,

Hope you managed to hit your deadline. Would be interested to see how
you resolved this.

I have written a seris of forms that can be pre-populated with XML
data. The simplest solution I could come up with to use XSL to
generate the HTML form. Although I have the advantage that the XML is
controlled by me. An XSD (XML definition) file is always very useful
when you rely on someone elses XML. This will show you the layout of
the document, as the developer designed it, and could give you some
insight in to how to work with it.

The XML snip you present doesn't look very well defined. If you know
who does control the XML output I would suggest they read some books or
check the internet on using XML and presenting it as API output. If
this is a published API (internal or external) the format shouldn't
change without pre-warning.

Steve

Closed Thread