OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] xml question - new line

[ Lists Home | Date Index | Thread Index ]



**Where do you want to add a newline?  All you are doing is setting an
attribute
**on an element... do you want to include the newline in the value of the
**attribute, or between elements, or what?

**I want to add a newline after certain attributes and after certain
elements.

Here is a better code snippet:

CFileDialog dlg(false, "xml", "*.xml",
// The following flag options are a combination of defaults along
// with OFN_NOCHANGEDIR to keep the default dialog directory the
// same regardless of user navigation.
//OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR);
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT);

if(dlg.DoModal() == IDOK)
{
	CString fileName = dlg.GetFileName();
	CXMLInterface xmlDomInterface;
	HRESULT hr = S_OK;
	MSXML::IXMLDOMNodePtr pRootNode, pNode, pChildNode,pSubChildNode = NULL;

	hr = xmlDomInterface.CreateEmptyDocument();
	CHECKHR(hr);

	//Create the root
	pRootNode =
xmlDomInterface.CreateRootElement(ucrPMFileName.AllocSysString());
	for(i=0;i<MAX;i++)
	{
		tmpNum = GetNumber(i);

**I don't know C++ very well, but what is the point of this?  Every time
through
**the loop, you overwrite the value of tmpNum.  Why not just remove the loop
**and say 'tmpNum = GetNumber(MAX-1);'?
** No, not in this case because depending on the value I get from GetNumber
is whether or not it ** is added to the count.  Every time I go through the
loop I get different values and they are
** saved in the xml output.

		tmpB3 = GetBx3/10.0(i);
		tmp1Fp = GetType(i);
		tmpDShelf = GetDShelf(i);
		tmpFShelf = GetFShelf(i);
		tmpFpNum = GetFpNum(i);
		pNode = xmlDomInterface.CreateDOMNode(MSXML::NODE_ELEMENT,
uName[0].AllocSysString());
		hr = pRootNode->appendChild(pNode);
		CHECKHR(hr);
		hr =
xmlDomInterface.SetAttribute(pNode,attribName[i].AllocSysString(),tmpNum);
		CHECKHR(hr);
		tmpStr.Format(_T("%.2f"), tmpBx3);
		hr =
xmlDomInterface.SetAttribute(pNode,attribName[i].AllocSysString(),tmpStr.All
ocSysString());
		CHECKHR(hr)
		hr =
xmlDomInterface.SetAttribute(pNode,attribName[i].AllocSysString(),fNumber[tm
pDShelf].AllocSysString());
		CHECKHR(hr);
		hr =
xmlDomInterface.SetAttribute(pNode,attribName[i].AllocSysString(),tmpFShelf)
;
		CHECKHR(hr);
	}


		// Save document

		hr = xmlDomInterface.Save(fileName.AllocSysString());
		CHECKHR(hr);

CleanUp:
		_com_error er(hr);
		AfxMessageBox(er.ErrorMessage());

	} //if doModal

-----Original Message-----
From: pdavis152@attbi.com [mailto:pdavis152@attbi.com]On Behalf Of Peter
Davis
Sent: Friday, July 19, 2002 4:50 PM
To: Nicole Redmond; xml-dev@lists.xml.org
Subject: Re: [xml-dev] xml question - new line


On Friday 19 July 2002 12:30, Nicole Redmond wrote:
> How do I add a new line to the XML displayed in the browser and in the
file
> opened by a text editor such as Notepad without changing all of the ints
to
> strings?

Where do you want to add a newline?  All you are doing is setting an
attribute
on an element... do you want to include the newline in the value of the
attribute, or between elements, or what?


>[...]

>         for(i=0;i<MAX;i++)
>         {
>                 tmpNum    = GetNumber(i);
>                 //many other ints defined here
>         }

I don't know C++ very well, but what is the point of this?  Every time
through
the loop, you overwrite the value of tmpNum.  Why not just remove the loop
and say 'tmpNum = GetNumber(MAX-1);'?

Did you mean to have the code that follows this (where you create the
element
and set the attribute) inside of the loop?

--
Peter Davis

-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS