Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / January 2004

Tip: Looking for answers? Try searching our database.

i want to kill xmlreader and all her children

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
x0td - 28 Jan 2004 23:03 GMT
please reply via email to this post to x0td0x@hotmail.com
i need some code that will generate code to read the xml file it is
reading

for example
input:
<book>
<bk:title>the wind</bk:title>
<bk:content
type="text">howl</bk:content>
</book>output: (xtw=xmltextwriter)
[code:1:10bb0ab988]xtw.WriteStartElement("book");
xtw.WriteStartElement("bk:title");
xtw.WriteString("the wind");
xtw.WriteEndElement();
xtw.WriteStartElement("bk:content");
xtw.WriteAttributeString("type","text");
xtw.WriteString("howl");
xtw.WriteEndElement();
xtw.WriteEndElement();[/code:1:10bb0ab988]

just solve that if you can!
seems simple?
i want to cry, i tried xmltextreader
and xmlnodereader, both would not work exactly how i wanted
i do not understand while during a
[code:1:10bb0ab988]while (xtr.read())
    console.writeline(xtr.name)[/code:1:10bb0ab988]
for the input
[code:1:10bb0ab988]<book>
stuff
</book>[/code:1:10bb0ab988]

the result is
book

book <<<< WHY IS THIS HERE, CANT IT TELL ITS THE SAME
ELEMENT!!
Daniel Cazzulino - 30 Jan 2004 18:46 GMT
You're writing the XML the wrong way. The element:

<bk:title>the wind</bk:title>

is made of a prefix "bk" a name "title" and a string content "the wind".

The way to write this is:

xtw.WriteElementString("title", "http://myurnforbooks", "the wind");

Note that the prefix is irrelevant. What matters is the namespace. When you
read the xml back, the only thing you should care is the namespace and
local name of the element.

For input <book>stuff</book>, the reader will subsequently pass over the
document element, the text content, and the closing element in turn, each
time you call Read(). Remember the reader is a cursor over the underlying
XML. For each infoset item (element, attribute, text, etc.) the cursor is
advanced after each Read() call.
You get the "book" string in the output twice because first it's an open
elemnt and later a closing tag. If you ask for the reader's NodeType
property, you will see that it's  XmlNodeType.Element the first time, and
XmlNodeType.EndElement the second.
They are different things.

> please reply via email to this post to x0td0x@hotmail.com
> i need some code that will generate code to read the xml file it is
[quoted text clipped - 36 lines]
>
> ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
News==----
> http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
> ---=
=---

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.