JGLP

Hi
how can i write (and read) to a XML file on this format:

<color id="red">
</color>

If i use:
DataWrite->WriteElementString("color","red");
will appear like: <color>red</color>

and if i use:
DataWrite->WriteStartElement("color",nullptr,"red");
will appear like:
<color xmlns:color="red">

thanks!!


Re: Visual C++ General About XmlTextWriter

Bite Qiu - MSFT

Hi,

You need WriteEndElement() to close you tag.

Code Snippet
DataWrite->WriteStartElement("Tag1", "2000");
DataWrite->WriteAttributeString("Attribute", "somevalue");
DataWrite->WriteEndElement();

which outputs:

<Tag1 Attribute="Somevalue>2000</Tag1>






Re: Visual C++ General About XmlTextWriter

JGLP

hi there
i didn't need to write in this format, but now i need to read XML files like
<color id="red">blabla<color>

i need to get the "RED" from the ID...
i allready used the methods

[visual c++]
if(DataRead->NodeType == XmlNodeType::Element && DataRead->Name=="color")
{
String^ s;
//s= DataRead->ReadElementString();
//s=DataRead->ReadContentAsString();
//s=DataRead->ReadElementContentAsString();
s=DataRead->ReadInnerXml();
s=DataRead->ReadOuterXml();
s=DataRead->ReadString();
}

the lines that have // had return exceptions
and the others i didn¡¯t get the ID=red Sad

anyone knows how i can accomplish this
thanks in advance




Re: Visual C++ General About XmlTextWriter

Ðãv? S. Â???????

Post your issue in the XML and the .NET Framework forum. They can better help you.





Re: Visual C++ General About XmlTextWriter

JGLP

thanks, i did as you said. the solution:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1798758&SiteID=1