473,396 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

i want to kill xmlreader and all her children

please reply via email to this post to x0****@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!!

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 12 '05 #1
1 1506
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.

"x0td" <x0****@hotmail-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
please reply via email to this post to x0****@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!!

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Pif Paf | last post by:
I am writing programs that will run as TCP servers. Briefly, I want to set up a TCP server on a port in such a way that if another server is already sitting on that port (both servers are Python...
2
by: veganeater | last post by:
Hello again everyone, I seem to have run into another problem... perhaps I'm just a bit slow. The problem is something like this: I have a popup window launched by a page sourced in an iFrame ...
2
by: xmlguy | last post by:
Cant seem to solve this problem I need to be able to re-use XmlReader and XPathDocument for an XSLT Transform. Basically I have defined following interfaces: Class Render (Common and...
0
by: x0td | last post by:
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>...
1
by: Angus Lepper | last post by:
I'm writing a stock ticker for a stock market simulation, and can load the data into the xmlreader in the first place, but can't figure out how to refresh/update the data in it. Any ideas? Code:...
0
by: Jen | last post by:
My main question: "How can I get a TextReader or Stream object from an existing XmlReader?". Read on for more: I have an existing XmlReader. Let's call it reader1. I'm creating another reader,...
1
by: randy1200 | last post by:
The following is straight out of the msdn, except where I put in if (reader.Name == "wx") What I'm trying to do is print the word Inner along with the tag name and value for any tag that's a...
1
by: Vivienne | last post by:
Hi there This is a hard problem that I have - I have only been using sql for a couple of weeks and have gone past my ability level quickly! The real tables are complex but I will post a simple...
5
by: heday60 | last post by:
I've got this application that watches a directory for XML's and then parses them into a DB. It then moves them based on if the XML was succesful or a bad XML... foreach(FileInfo file in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.