AttributeNodeSuggestion?

  • Thread starter Thread starter farseer
  • Start date Start date
F

farseer

XMLNode.ChildNodeSuggestions can be called to retrieve a set of valid
child elements for a given node. Is there any equivalent for
attributes? If not, how can i determine at runtime what the valid
attributes are that i can add to an element?
 
Hi Farseer,

don't know where you find the Property "ChildNodeSuggestions" ?
I think the best way to make shure that your xml document match
a given schema is to use a xsd schemafile.
If you only want to know the attributes of a xml node you can
iterate over XmlAttributeCollection of the node.

Example:

string xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"
+"<lists><list id=\"1\">In here</list></lists>";

XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(xml);

XmlNodeList xnllists = xmldoc.SelectNodes("/lists/list");
foreach(XmlNode xnlist in xnllists)
foreach(XmlAttribute xnchildattr in xnlist.Attributes)
Console.WriteLine(xnchildattr.InnerText);


Cheers
Lars Behrmann

_________________
Nothing is impossible. UML is the key for all your problems.
AODL - Make your .net apps OpenOffice ready
http://aodl.sourceforge.net
 
I can get the attributes of existing elements fine. it's when it come
time to adding a node that's the problem.

the method is from Microsoft.Office.Word.Interop.XmlNode...a truly sick
beast whose existence i can't understand. it doesn't even have an
"insertXML" method, which would have made things i am trying to a lot
easier.

i am taking a different approach to solve my problem and running into
road blocks there also.
right now i am serializing some objects as xml and i want to insert
them into the underlying WordML...there doesn't seem to be an easy way
of doing that using Microsoft.Office.Word.Interop.XmlNode. i cant do
an InsertXML on the serialized XML. i cant find any way on
Microsoft.Office.Word.Interop.XmlNode of easily inserting another child
node from anohter XMLNode. so i have to do it the long way...create
the node, name it, and add it's attributes and elements manually. i do
this thru reflection. the problem is, thru reflection, i am cant
distinguish between what should be an attribute propert or an
elment...and i the sequence is not guarantied if i am trying to add as
xml, an object that extends another object.
 
Back
Top