|
Hi everyone,
I am having trouble parsing a certain XML structure. I am trying to create an ASP.NET based flowchart editor. All the state transitions etc. are stored as XML and I was hoping to read the XML into appropriate data structures and render them using the graphics library for ASP.NET.
Here is an example XML for a very simple flow chart:
<begin>
<decision> // a deision tree
<value>(x == y OR y == z)</value> // condition
<option>
<value>No</value> // condition not met
<action>Do 1</action> // Do 1
</option>
<option>
<value>Yes</value> // condition met
<decision> // Another decision tree.
<value>a == b</value>
<option>
<value>No</value> +
<action>Do X</action>\n" +
</option>
<option>
<value>Yes</value>
<action>Do Y</action>
</option>
</decision> // sub decision
</option>
</decision> // main decision
</begin>
My problem is how do I parse this XML with such nested decision trees. Potentially they can go many level down. Do I have to use something like recursion here?
Some small example or code snippet would be really helpful.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
An XmlDataDocument isn't what you want. That's more for 2- or 3-level document structures that fit nicely into a DataSet . Just use the XmlDocument , or an XmlTextReader if you don't want to read the whole document into memory and creating a DOM from it. This really depends on your implementation, though.
If you're looking to extract information using XPath expressions, you might try an XPathDocument instead. Rather than creating some decision tree in memory, this would be good to just get what you need from the file (perhaps not the most efficient, but it's an option).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
Well, the application would not load very complicated and large XML files. However, my main problem is how to read such nested trees...
example
decision
----option
--------decision
-----------option
---------------decision
etc. As you can see, it goes multiple structures down and I could not come up with a way to read these.
Your advice for changing the XML reader class is well-received and I will change it to XmlTextReader.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Like I said, though - why you don't find the schema very complicated, it won't work with an XmlDataDocument , which only works with 2- and 3-level (only) data. It's basically just a serialized DataSet with all the XML bells and whistles.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Maybe my code snippet would helps you
FileStream fs = new FileStream("xml2.xml", FileMode.Open);
XmlTextReader xreader = new XmlTextReader(fs);
while(!xreader.EOF)
{
if(xreader.MoveToContent()==XmlNodeType.Element&&xreader.Name=="Name")
{
cbName.Items.Add(xreader.ReadElementString());
}
else
xreader.Read();
}
xreader.Close();
fs.Close();
www.xedom.com
|
|
|
|
|
In this example I reading xml file with the structure
<person informationabout="A">
<name>AAA
<phone>111
I parsing whole document looking for nodes with <name> tag.
www.xedom.com
|
|
|
|
|
I mean
<?xml version="1.0" ?>
<PhoneBook>
<person InformationAbout="Test">
<Name>Test</Name>
<Phone>55555555</Phone>
</person>
<person InformationAbout="WWW">
<Name>WWW</Name>
<Phone>8888888</Phone>
</person>
</PhoneBook>
<a href="http://www.xedom.com">
xedom developers team
</a>
|
|
|
|
|
What component library would you recommend for a general Windows Form application?
I am going to be doing some Windows Forms development soon and need to evaluate and purchase a good component library.
FeedDemon, Office 2003 and Visio are examples of applications which have the component look and functionality that I am looking for. What can give me that level of professional UI?
I hear Infragistics is a good set but I would like a few more options. Janus looks good too.
Obviously if there are free-to-use options available then that would be great to. But I realise I will probably have to pay to get a good toolset.
The app would be written in C# and .NET so the Dundas UltimateToolbox is out (I assume).
thanks all.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
There are a wide variety of controls, tools, and various utilities found in the free Ghengis Project[^].
#include "witty_sig.h"
|
|
|
|
|
Thanks Judah, will check it out.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
I've had pretty good experiences with Developer Express[^] and Infragistics[^]. For both, their products work with the theming API and have the toolbars you want.
They both have demos, and their prices are pretty good. Even an independent developer should be able to afford them.
I haven't really dug into the devexpress controls like I have with Infragistics (which we use the UltraWinTree in our product), but I will warn that Infragistics uses a very object-oriented, hierarchical design for drawing. It's a great idea in concept, but on slower machines you'll really notice (perhaps within reason, though).
For instance, with the UltraWinTree, there's a UI element for the client region, a separate one for each scrollbar (if/when applicable), separate ones for the lines, separate ones for each node, and then separates ones within those for the -/+ box, images (yes, plural), and the text. It is extensible, although not always intuitively so!
One more thing: Infragistics doesn't seem to like virtual methods and properties. I guess they just don't expect you to extend their classes (which I had to do for the UltraWinTree, which makes for a much better OO design the way we use our tree). So, things like the UltraTreeNode.Text property you can override. I came up with a kludge that works, but it definitely shows lack of foresight.
My suggestion would be to try them out, of course. Both are pretty good and overall I'm pleased with them.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you Heath, exactly the kind of info I am looking for. Real world use and experience. They all have flashy looking demos.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
I'm going to get my devexpress controls re-installed and check those out and compare. I've been thinking about dropping the UltraWinTree for something better, but I really need to compare. If I remember, I'll try to post back what I find (such as if Developer Express belives in good OO design with virtual methods and properties (where reasonable).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Thanks Michael, it comes with the Infragistics Ultra Win Tree which is great.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
|
Sub : How to use Amazon Web Services..
Hi all...
Please let me know How to start with amazon web services..
I'm not finding any XML or REST Query format to send request to amazon..
I've purchased Seller account but How to use that to upload Items..I don't know...
Please help me getting start..
I hope some one definatly know about this
e-mail if attachment at sumit_kapoor1980@hotmail.com
Thanks...
..---Sumit Kapoor---
|
|
|
|
|
Here are three articles on Code Project which tell you how:
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
Stop Cross posting and take a look: The answer is already on Code Project, if you would care to look.
My suggestion is to use the little search box near the top of this page and type "Amazon web services", ensure the drop down says "Articles" and then press "Go". You'll be amazed at what you can find.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|
|
The effect is the same, but which one is faster?
if(s == String.Empty)
or
if(s.Length == 0)
?
|
|
|
|
|
From Performance Strategies for Enterprise Web Site Development here on CP:
There is one more item I’d like to address when talking about strings, and that is checking for an empty string. There are two basic ways to check if a string is empty or not. You can compare the string to the String.Empty static property, which is just a constant for “”:
if (firstName == String.Empty)
Or you can check the length of the string, like this:
if (firstName.Length > 0)
I setup a test in the .NET Test Harness and found that the String.Empty comparison check was 370% slower than the length check. This may seem fairly trivial, but every little bit helps, right?
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
Paul is right. If you run your code through the FxCop assembly analyzer, it'll chide you for using if(myString == string.Empty), telling you to use if(myString.Length == 0) instead.
#include "witty_sig.h"
|
|
|
|
|
So why did they bother inventing String.Empty I wonder ?
Try not! Do or do not, there is no try. - Master Yoda
|
|
|
|
|
Because it's faster than loading your own literal "" when needed. There's still uses for it. Perhaps you want to initialize a string member as an empty string instead of null. Just because something may not be useful in one case doesn't mean it's not useful in another.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello! what can I convert a char* to string?
The cast isn't permitted!
Thanks
|
|
|
|