本文整理汇总了C#中org.NextContent方法的典型用法代码示例。如果您正苦于以下问题:C# org.NextContent方法的具体用法?C# org.NextContent怎么用?C# org.NextContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org
的用法示例。
在下文中一共展示了org.NextContent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
//.........这里部分代码省略.........
{
token = x.NextToken();
if (!(token is string))
{
throw x.SyntaxError("Missing value");
}
jsonobject.Accumulate(@string, org.json.XML.StringToValue((string)token));
token = null;
}
else
{
jsonobject.Accumulate(@string, string.Empty);
}
}
else
{
// Empty tag <.../>
if (token == SLASH)
{
if (x.NextToken() != GT)
{
throw x.SyntaxError("Misshaped tag");
}
if (jsonobject.Length() > 0)
{
context.Accumulate(tagName, jsonobject);
}
else
{
context.Accumulate(tagName, string.Empty);
}
return false;
}
else
{
// Content, between <...> and </...>
if (token == GT)
{
for (; ; )
{
token = x.NextContent();
if (token == null)
{
if (tagName != null)
{
throw x.SyntaxError("Unclosed tag " + tagName);
}
return false;
}
else
{
if (token is string)
{
@string = (string)token;
if (@string.Length > 0)
{
jsonobject.Accumulate("content", org.json.XML.StringToValue(@string));
}
}
else
{
// Nested element
if (token == LT)
{
if (Parse(x, jsonobject, tagName))
{
if (jsonobject.Length() == 0)
{
context.Accumulate(tagName, string.Empty);
}
else
{
if (jsonobject.Length() == 1 && jsonobject.Opt("content") != null)
{
context.Accumulate(tagName, jsonobject.Opt("content"));
}
else
{
context.Accumulate(tagName, jsonobject);
}
}
return false;
}
}
}
}
}
}
else
{
throw x.SyntaxError("Misshaped tag");
}
}
}
}
}
}
}
}
}
示例2: Copyright
/*
Copyright (c) 2008 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/// <summary>Parse XML values and store them in a JSONArray.</summary>
/// <param name="x">The XMLTokener containing the source string.</param>
/// <param name="arrayForm">true if array form, false if object form.</param>
/// <param name="ja">
/// The JSONArray that is containing the current tag or null
/// if we are at the outermost level.
/// </param>
/// <returns>A JSONArray if the value is the outermost tag, otherwise null.</returns>
/// <exception cref="JSONException"/>
/// <exception cref="org.json.JSONException"/>
private static object Parse(org.json.XMLTokener x, bool arrayForm, org.json.JSONArray ja)
{
string attribute;
char c;
string closeTag = null;
int i;
org.json.JSONArray newja = null;
org.json.JSONObject newjo = null;
object token;
string tagName = null;
// Test for and skip past these forms:
// <!-- ... -->
// <![ ... ]]>
// <! ... >
// <? ... ?>
while (true)
{
if (!x.More())
{
throw x.SyntaxError("Bad XML");
}
token = x.NextContent();
if (token == org.json.XML.LT)
{
token = x.NextToken();
if (token is char)
{
if (token == org.json.XML.SLASH)
{
// Close tag </
token = x.NextToken();
if (!(token is string))
{
throw new org.json.JSONException("Expected a closing name instead of '" + token + "'.");
}
if (x.NextToken() != org.json.XML.GT)
{
throw x.SyntaxError("Misshaped close tag");
}
return token;
}
else
{
if (token == org.json.XML.BANG)
{
// <!
c = x.Next();
if (c == '-')
{
if (x.Next() == '-')
{
x.SkipPast("-->");
}
else
{
x.Back();
}
}
else
{
if (c == '[')
{
token = x.NextToken();
if (token.Equals("CDATA") && x.Next() == '[')
{
if (ja != null)
{
//.........这里部分代码省略.........