|
I am an XML rookie and need some help. I am creating a project to poll web applications and other apps and of there is an error I want to send an email. I would like to poll the different apps listed in my XML. I want to pull back a application and its attributes. I have tried the XPathNavigator methods
with little success. Any help would be appreciated as to how to approach this problem or some good basic XML instructions. Here is the XML I created maybe I need to do it differently.
<applications xmlns="http://tempuri.org/Applications.xsd">
<application>
<name>Volunteer Email
<url>http://ftwweb02/volemail/report4.asp
<apptype>web
<databaseconnectionstring>
<database>
<emailaddresstonotify>BobSmith@texashealth.org
<fullpath>
<testtime>60000
<timeout>20000
<application>
<name>XBox App
<url>none
<apptype>database
<databaseconnectionstring>pwd=214;uid=me
<database>
<emailaddresstonotify>GeraldStanford@texashealth.org
<fullpath>
<testtime>60000
<timeout>20000
|
|
|
|
|
Hi,all
I have few issues with Xslt transfer xml to xml
1: xml is from a string, how xslt transfer a dynamcally generated string instead of a file;
2: I transfer xml to xml string by xslt, but the XML
string can't be validated by schema. the thing is that if I load the generated XML string into VS studio and save it,which become a file. it can be validated. or it is valid if I just add a blank
space anywhere.
It might be the format issue with file and string, but I think it is weired.
|
|
|
|
|
add 1) System.Xml.XsltTransform.Transform() method accepts TextWriter as an argument (see MSDN[^]). StringWriter is derived from TextWriter, so...
hi,
add 2) similarly, System.Xml.XmlValidatingReader constructor takes XmlReader as argument. Xmlreader can read from stream. and string can be written into stream (e.g System.IO.MemoryStream ).
I only made some searches at MSDN and didn't try it. Let me know if there is any problem
Does it help?
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hi,David:
1. yes, you are right for the first problem. I am using a StringReader to read the string and then use the XMLtextReader to read that stringReader,
2. NO. it wasn't that issue, the issue is that the decodeing problem, I need to change it to UTF-8, then done. thanks.
|
|
|
|
|
hi,
I don't understand to your problem than. You have XML in string, right? and you want to validate it with XmlValidatingReader.. And there is problem with encoding? How you get that xml string? from file? in which encoding it is? See this MSDN[^]
which encodings are supported by XmlTextReader. If it's not your case see System.Text.Encoding etc.. sry I must go now I'll look at it later.
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
when the xml string was generated, it was UTF-16, the XmlValidatingReader can't take it. ( For some reason, but might not this issue), I just changed it by UTF-8 using String.replace, and it is working now.
thank you very much.
|
|
|
|
|
titabonbon wrote:
thank you very much
lol you bring up question, force me to look at it, than you post answer (so I learned something I didn't know before) and than you thank me! Wonderful
marry christmas!
FYI: "All the encoding standards that the underlying operating system supports are supported." MSDN[^]
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
oh, sorry.
because my project is on due, I have to do whatever I can, fortunately I solved it. but I want to thank you for your help sincerely. and I just gave you some reference maybe it can help sometime.
happy holiday.
|
|
|
|
|
titabonbon wrote:
oh, sorry.
No I didn't mean it ironic!
happy holiday to you too
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hi,
I have one question about System.Xml.XmlAttribute class. Why it has ChildNodes property? Attributes cannot have child nodes, right? Is it bad design or did I miss something? Plz don't post answers like it's because XmlAttribute is derived from XmlNode . I know. I just don't know WHY? There is probably no case when it can be useful, since when I tried to append element to attribute (weird, I know ) it throws an exception
Unhandled Exception: System.InvalidOperationException: The specified node cannot<br />
be inserted as the valid child of this node, because the specified node is the<br />
wrong type.<br />
What is your opinion/explanation? Or give me some links to people who will answer this (.NET designers maybe?)...
Thx a lot for some ideas or suggestions!
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Readup on Abstracting base functionality into a Base implementation, together with polymorphism and you may understand why EVERYTHING in the Xml tree derives from XmlNode.
|
|
|
|
|
hi,
thanks for your reply. I think I understand why everything derives from same base class... I am working on html parser these days and that made me think about it afer all. Bt I think it's either wrong to give XmlNode ability to have child nodes, or it's wrong to make XmlNode as base class. According to W3C recomendation, attribute is name-value pair. Well I don't understand to tokens, entities etc. (anyway I'll hopefully study it ) .. does it allow node* as value? I don't think so. I may be wrong and in case I am wrong, plz correct me.
IMO XmlNode has too much abilities. I'd make even more basic class as base for XmlNode, and derive XmlAttribute from this base class. (actually I do in my project) I am really at the beginning of true understanding to OOP, so plz tell me if it's ok so and why/why not. I simply can't see why atrribute could have child nodes. It's (slightly) bad design IMO.
thank you
David
*I think of value like something atomic, not with hierarchy - thats why i don't like child nodes there
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hi all,
I want to trap all the error messages in my application to a Xml file format.So that it goes on appending the nodes whenever a new error occurs.How to accomplish this.Can anyone help me.....
Thanks in advance
|
|
|
|
|
|
Hi,
does anybody know some links or articles about transforming the schema-xml file of datasets to code?
Especially for Data Access Classes this is useful.
I already did this once but maybe there are some generic solutions out there which could be of use.
Thanks...
|
|
|
|
|
How can I get support for XSLT 2.0 and XPath 2.0 in .NET. Is there an assembly I need to reference or any other download?
Jim
|
|
|
|
|
|
Thanks for your answer.
You are right, Microsoft's decision not to provide support is unforgivable.
Jim
|
|
|
|
|
I have a 3rd-party app that generates some "almost XML" files that I need to parse.
It has elements similar to the following:
<color
name = "Black"
colorspace = "CMYK"
cyan = 0.000000
magenta = 0.000000
yellow = 0.000000
black = 100.000000
/>
Notice that the attributes with numeric values aren't quoted as they should be.
There are also a few empty elements that appear as <data > (the element name and three spaces), although it's an empty element and should be <data /> .
These two deviations from true XML are making it impossible for me to simply load the XML into an XMLDocument so that I can easily access the elements I need.
I don't normally work with XML a whole lot. I was wondering if anyone knows of any "simple" methods or an existing library that can correct these errors in the XML as it's read from the file.
The empty element problem I think I can deal with pretty easily with a simple search/replace, as it seems there's only one element in the file that's ever munged this way, but the missing quotes problem is much bigger, as 99% of the numeric attribures are broken, in all elements.
TIA for any help with this.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
hi,
Library you need will (hopefully) be my school work meanwhile, you can check HTML Tidy (http://www.w3.org/People/Raggett/tidy/[^]) It has some XML support.
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Thanks, David.
I took a look at Tidy, but since it's specific to HTML and won't process a file with unknown tags, it won't work for me in its existing incarnation.
The source code, however, will give me some good insight into how to parse the XML and correct it myself on-the-fly.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
I would think that a Regular Expression would be the best way to fix this - RegExp
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hello Everyone,
Im building an xmldocument, I need to create a node that has this structure,
<user ID="10"/>, but I can't figure it out. Im sure this is stupid, but what XmlNodeType should I be using for this, along with anything else I need.
Thanks for the help!
Ryan
|
|
|
|
|
hi,
this is element
can be inserted into XmlDocument in many ways,
e.g:
<br />
doc.documentElement.Nodes.<br />
XmlElement node = doc.CreateElement(null,"user",null);<br />
XmlAttribute attr = doc.CreateAttribute(null,"ID",null);<br />
attr.Value="10";<br />
node.Attributes.Append(attr);<br />
doc.DocumentElement.AppendChild(node);<br />
Does it help?
There are more ways how to insert element into xml document, check MSDN for more...
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|